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 java.io.Serializable; 022 023import org.nuxeo.common.xmap.annotation.XNode; 024import org.nuxeo.common.xmap.annotation.XObject; 025import org.nuxeo.ecm.platform.query.api.AggregateRangeDefinition; 026 027/** 028 * @since 6.0 029 */ 030@XObject("range") 031public class AggregateRangeDescriptor implements AggregateRangeDefinition, Serializable { 032 033 private static final long serialVersionUID = 1L; 034 035 @XNode("@key") 036 public String key; 037 038 public AggregateRangeDescriptor() { 039 } 040 041 @XNode("@from") 042 public Double from; 043 044 @XNode("@to") 045 public Double to; 046 047 public AggregateRangeDescriptor(String key, Double from, Double to) { 048 this.key = key; 049 this.from = from; 050 this.to = to; 051 } 052 053 @Override 054 public String getKey() { 055 return key; 056 } 057 058 @Override 059 public Double getFrom() { 060 return from; 061 } 062 063 @Override 064 public Double getTo() { 065 return to; 066 } 067 068 @Override 069 public void setKey(String key) { 070 this.key = key; 071 } 072 073 @Override 074 public void setFrom(Double from) { 075 this.from = from; 076 } 077 078 @Override 079 public String toString() { 080 return String.format("AggregateRangeDescriptor(%s, %s, %s)", key, from, to); 081 } 082 083 @Override 084 public void setTo(Double to) { 085 this.to = to; 086 } 087 088 @Override 089 public AggregateRangeDefinition clone() { 090 AggregateRangeDescriptor clone = new AggregateRangeDescriptor(key, from, to); 091 return clone; 092 } 093}