001/* 002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Benoit Delbosc 018 */ 019package org.nuxeo.ecm.platform.query.core; 020 021import org.nuxeo.common.xmap.annotation.XNode; 022import org.nuxeo.common.xmap.annotation.XObject; 023import org.nuxeo.ecm.platform.query.api.AggregateRangeDateDefinition; 024 025/** 026 * @since 6.0 027 */ 028@XObject("dateRange") 029public class AggregateRangeDateDescriptor extends AggregateRangeDescriptor implements AggregateRangeDateDefinition { 030 031 public AggregateRangeDateDescriptor() { 032 } 033 034 public AggregateRangeDateDescriptor(String key, String from, String to) { 035 this.key = key; 036 fromDate = from; 037 toDate = to; 038 } 039 040 @XNode("@fromDate") 041 public String fromDate; 042 043 @XNode("@toDate") 044 public String toDate; 045 046 @Override 047 public String toString() { 048 return String.format("AggregateRangeDateDescriptor(%s, %s, %s)", key, fromDate, toDate); 049 } 050 051 @Override 052 public String getFromAsString() { 053 return fromDate; 054 } 055 056 @Override 057 public String getToAsString() { 058 return toDate; 059 } 060 061 @Override 062 public void setFrom(String from) { 063 fromDate = from; 064 this.from = null; 065 } 066 067 @Override 068 public void setTo(String to) { 069 toDate = to; 070 this.to = null; 071 } 072 073 @Override 074 public AggregateRangeDateDefinition clone() { 075 AggregateRangeDateDescriptor clone = new AggregateRangeDateDescriptor(key, fromDate, toDate); 076 return clone; 077 } 078}