Package com.google.appengine.api.search
Class FacetRequest.Builder
- java.lang.Object
-
- com.google.appengine.api.search.FacetRequest.Builder
-
- Enclosing class:
- FacetRequest
public static final class FacetRequest.Builder extends Object
A facet request builder. Each facet request should at least have thenameof the facet. It can also includes number of values, a list of constraints on the values or a list of ranges for numeric facets. Note that the list of constraints and the list of ranges are mutually exclusive, i.e. you can specify one of them but not both.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FacetRequest.BuilderaddRange(FacetRange range)Adds aFacetRangeto this request.FacetRequest.BuilderaddValueConstraint(String constraint)Adds a valueconstraintto this facet request.FacetRequestbuild()Construct the final message.FacetRequest.BuildersetName(String name)Sets the name of the facet for this request.FacetRequest.BuildersetValueLimit(int valueLimit)Sets the maximum number of values for this facet to return.
-
-
-
Method Detail
-
setValueLimit
public FacetRequest.Builder setValueLimit(int valueLimit)
Sets the maximum number of values for this facet to return.- Returns:
- this Builder
- Throws:
IllegalArgumentException- if valueLimit is negetive or zero or greater thanSearchApiLimits.FACET_MAXIMUM_VALUE_LIMIT
-
setName
public FacetRequest.Builder setName(String name)
Sets the name of the facet for this request.- Returns:
- this Builder
- Throws:
IllegalArgumentException- if name is empty or longer thanSearchApiLimits.MAXIMUM_NAME_LENGTH
-
addValueConstraint
public FacetRequest.Builder addValueConstraint(String constraint)
Adds a valueconstraintto this facet request. Note that ranges and value constraints are mutually exclusive. Either of them can be provided, but not both for the same request.- Returns:
- this Builder
- Throws:
IllegalArgumentException- if the constraint empty or longer thanSearchApiLimits.MAXIMUM_ATOM_LENGTH.IllegalStateException- if any number of ranges orSearchApiLimits.FACET_MAXIMUM_CONSTRAINTSconstraints have already been added.
-
addRange
public FacetRequest.Builder addRange(FacetRange range)
Adds aFacetRangeto this request. Note that ranges and value constraints are mutually exclusive. Either of them can be provided, but not both for the same request.- Returns:
- this Builder
- Throws:
NullPointerException- ifrangeis null.IllegalStateException- if constraints list is not empty or number of ranges became greater than SearchApiLimits.FACET_MAXIMUM_RANGES by adding this range.
-
build
public FacetRequest build()
Construct the final message.- Returns:
- the FacetRequest built from the parameters entered on this Builder
- Throws:
IllegalArgumentException- if the facet request is invalid
-
-