Class FacetChecker


  • public final class FacetChecker
    extends Object
    Provides checks for Facet names and values: atom or number.
    • Method Detail

      • checkFacetName

        public static String checkFacetName​(String name,
                                            String callerContext)
        Checks whether a facet name is valid. The facet name length must be between 1 and SearchApiLimits.MAXIMUM_NAME_LENGTH inclusive, and it should match SearchApiLimits.FIELD_NAME_PATTERN.
        Parameters:
        name - the facet name to check
        callerContext - the caller context used for creating error message in case of a failure.
        Returns:
        the checked facet name
        Throws:
        IllegalArgumentException - if the facet name is empty or is longer than SearchApiLimits#MAXIMUM_NAME_LENGTH or it doesn't match #FIELD_NAME_PATTERN.
      • checkAtom

        public static String checkAtom​(String value)
        Checks whether an atom is valid. An atom can be null or a string between 1 and SearchApiLimits.MAXIMUM_ATOM_LENGTH in length, inclusive.
        Parameters:
        value - the atom value to check
        Returns:
        the checked atom
        Throws:
        IllegalArgumentException - if atom is too long or too short (i.e. empty)
      • checkFacetValue

        public static com.google.apphosting.api.search.DocumentPb.FacetValue checkFacetValue​(com.google.apphosting.api.search.DocumentPb.FacetValue value)
        Checks whether a facet value is valid.
        Parameters:
        value - the facet value to check
        Returns:
        the checked facet value
        Throws:
        IllegalArgumentException - if the facet value type is not recognized or if the facet value string is not valid based on the type. See checkNumber(java.lang.Double) and checkAtom(java.lang.String).
      • checkValid

        public static com.google.apphosting.api.search.DocumentPb.Facet checkValid​(com.google.apphosting.api.search.DocumentPb.Facet facet)