All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.enonic.xp.query.aggregation.AbstractRangeAggregationQuery Maven / Gradle / Ivy

The newest version!
package com.enonic.xp.query.aggregation;

import java.util.Collection;
import java.util.HashSet;

import com.google.common.collect.ImmutableSet;

import com.enonic.xp.annotation.PublicApi;

@PublicApi
public abstract class AbstractRangeAggregationQuery
    extends BucketAggregationQuery
{
    private final String fieldName;

    private final ImmutableSet ranges;

    AbstractRangeAggregationQuery( final Builder builder, final Collection ranges )
    {
        super( builder );
        this.ranges = ImmutableSet.copyOf( ranges );
        this.fieldName = builder.fieldName;
    }

    public ImmutableSet getRanges()
    {
        return ranges;
    }

    public String getFieldName()
    {
        return fieldName;
    }

    public abstract static class Builder
        extends BucketAggregationQuery.Builder
    {
        private String fieldName;

        public Collection ranges = new HashSet<>();

        public Builder( final String name )
        {
            super( name );
        }

        public T addRange( final R range )
        {
            ranges.add( range );
            return (T) this;
        }

        public T setRanges( final Collection ranges )
        {
            this.ranges = ranges;
            return (T) this;
        }

        public T fieldName( final String fieldName )
        {
            this.fieldName = fieldName;
            return (T) this;
        }
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy