com.enonic.xp.query.aggregation.AbstractRangeAggregationQuery Maven / Gradle / Ivy
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;
}
}
}