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 java.lang.Object

  A facet request builder. Each facet request should at least have the `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.

- - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### setValueLimit

          public FacetRequest.Builder setValueLimit(int valueLimit)

      Sets the maximum number of values for this facet to return.
      Returns:
        this Builder
      Throws:
        `java.lang.IllegalArgumentException` - if valueLimit is negetive or zero or greater than `SearchApiLimits.FACET_MAXIMUM_VALUE_LIMIT`

    - #### setName

          public FacetRequest.Builder setName(java.lang.String name)

      Sets the name of the facet for this request.
      Returns:
        this Builder
      Throws:
        `java.lang.IllegalArgumentException` - if name is empty or longer than `SearchApiLimits.MAXIMUM_NAME_LENGTH`

    - #### addValueConstraint

          public FacetRequest.Builder addValueConstraint(java.lang.String constraint)

      Adds a value `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.
      Returns:
        this Builder
      Throws:
        `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.

    - #### addRange

          public FacetRequest.Builder addRange(FacetRange range)

      Adds a `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.
      Returns:
        this Builder
      Throws:
        `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.

    - #### build

          public FacetRequest build()

      Construct the final message.
      Returns:
        the FacetRequest built from the parameters entered on this Builder
      Throws:
        `java.lang.IllegalArgumentException` - if the facet request is invalid