001/* 002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl-2.1.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Benoit Delbosc 016 */ 017package org.nuxeo.ecm.platform.query.core; 018 019import java.io.Serializable; 020 021import org.nuxeo.common.xmap.annotation.XNode; 022import org.nuxeo.common.xmap.annotation.XObject; 023import org.nuxeo.ecm.platform.query.api.AggregateRangeDefinition; 024 025/** 026 * @since 6.0 027 */ 028@XObject("range") 029public class AggregateRangeDescriptor implements AggregateRangeDefinition, Serializable { 030 031 private static final long serialVersionUID = 1L; 032 033 @XNode("@key") 034 public String key; 035 036 public AggregateRangeDescriptor() { 037 } 038 039 @XNode("@from") 040 public Double from; 041 042 @XNode("@to") 043 public Double to; 044 045 public AggregateRangeDescriptor(String key, Double from, Double to) { 046 this.key = key; 047 this.from = from; 048 this.to = to; 049 } 050 051 @Override 052 public String getKey() { 053 return key; 054 } 055 056 @Override 057 public Double getFrom() { 058 return from; 059 } 060 061 @Override 062 public Double getTo() { 063 return to; 064 } 065 066 @Override 067 public void setKey(String key) { 068 this.key = key; 069 } 070 071 @Override 072 public void setFrom(Double from) { 073 this.from = from; 074 } 075 076 @Override 077 public String toString() { 078 return String.format("AggregateRangeDescriptor(%s, %s, %s)", key, from, to); 079 } 080 081 @Override 082 public void setTo(Double to) { 083 this.to = to; 084 } 085 086 @Override 087 public AggregateRangeDefinition clone() { 088 AggregateRangeDescriptor clone = new AggregateRangeDescriptor(key, from, to); 089 return clone; 090 } 091}