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