com.enonic.xp.query.aggregation.GeoDistanceAggregationQuery Maven / Gradle / Ivy
package com.enonic.xp.query.aggregation;
import com.google.common.base.MoreObjects;
import com.enonic.xp.annotation.PublicApi;
import com.enonic.xp.util.GeoPoint;
@PublicApi
public class GeoDistanceAggregationQuery
extends AbstractRangeAggregationQuery
{
private final GeoPoint origin;
private final String unit;
private GeoDistanceAggregationQuery( final Builder builder )
{
super( builder, builder.ranges );
this.origin = builder.origin;
this.unit = builder.unit;
}
public GeoPoint getOrigin()
{
return origin;
}
public String getUnit()
{
return unit;
}
@Override
public String toString()
{
return MoreObjects.toStringHelper( this ).
omitNullValues().
add( "fieldName", getFieldName() ).
add( "ranges", getRanges() ).
add( "origin", origin ).
add( "unit", unit ).
toString();
}
public static Builder create( final String name )
{
return new Builder( name );
}
public static final class Builder
extends AbstractRangeAggregationQuery.Builder
{
private GeoPoint origin;
private String unit;
private Builder( final String name )
{
super( name );
}
public Builder origin( GeoPoint origin )
{
this.origin = origin;
return this;
}
public Builder unit( String unit )
{
this.unit = unit;
return this;
}
public GeoDistanceAggregationQuery build()
{
return new GeoDistanceAggregationQuery( this );
}
}
}