public static final class FacetRequest.Builder
extends java.lang.Object
name
of 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.Modifier and Type | Method and Description |
---|---|
FacetRequest.Builder |
addRange(FacetRange range)
Adds a
FacetRange to this request. |
FacetRequest.Builder |
addValueConstraint(java.lang.String constraint)
Adds a value
constraint to this facet request. |
FacetRequest |
build()
Construct the final message.
|
FacetRequest.Builder |
setName(java.lang.String name)
Sets the name of the facet for this request.
|
FacetRequest.Builder |
setValueLimit(int valueLimit)
Sets the maximum number of values for this facet to return.
|
public FacetRequest.Builder setValueLimit(int valueLimit)
java.lang.IllegalArgumentException
- if valueLimit is negetive or zero or greater than
SearchApiLimits.FACET_MAXIMUM_VALUE_LIMIT
public FacetRequest.Builder setName(java.lang.String name)
java.lang.IllegalArgumentException
- if name is empty or longer than
SearchApiLimits.MAXIMUM_NAME_LENGTH
public FacetRequest.Builder addValueConstraint(java.lang.String constraint)
constraint
to 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.java.lang.IllegalArgumentException
- if the constraint empty or longer
than SearchApiLimits#FACET_MAXIMUM_VALUE_LENGTH
.java.lang.IllegalStateException
- if any number of ranges or
SearchApiLimits.FACET_MAXIMUM_CONSTRAINTS
constraints have already been added.public FacetRequest.Builder addRange(FacetRange range)
FacetRange
to this request.
Note that ranges and value constraints are mutually exclusive. Either of
them can be provided, but not both for the same request.java.lang.NullPointerException
- if range
is null.java.lang.IllegalStateException
- if constraints list is not empty or number of ranges became
greater than SearchApiLimits.FACET_MAXIMUM_RANGES by adding this range.public FacetRequest build()
java.lang.IllegalArgumentException
- if the facet request is invalid