Class FilterBuilder


  • public final class FilterBuilder
    extends Object
    FilterBuilder creates a filter that will match any ConnectorObject that satisfies all of the selection criteria that were specified using this builder.
    Since:
    1.0
    Author:
    Will Droste
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Filter and​(Collection<Filter> subFilters)
      Creates a new "AND" filter using the provided list of sub-filters.
      static Filter and​(Filter... subFilters)
      Creates a new "AND" filter using the provided list of sub-filters.
      static Filter and​(Filter leftHandSide, Filter rightHandSide)
      Logically "ANDs" together the two specified instances of Filter.
      static Filter contains​(Attribute attr)
      Select only an input ConnectorObject with a value for the specified Attribute that contains as any substring the value of the specified Attribute.
      static Filter containsAllValues​(Attribute attr)
      Select only an input ConnectorObject with a value for the specified Attribute that contains all the values from the specified Attribute.
      static Filter endsWith​(Attribute attr)
      Select only an input ConnectorObject with a value for the specified Attribute that contains as a final substring the value of the specified Attribute.
      static Filter equalsIgnoreCase​(Attribute attr)
      Select only an input ConnectorObject with a value for the specified Attribute that is equal to, not considering the case the value of the specified Attribute.
      static Filter equalTo​(Attribute attr)
      Select only an input ConnectorObject with a value for the specified Attribute that is lexically equal to the value of the specified Attribute.
      static Filter greaterThan​(Attribute attr)
      Select only an input ConnectorObject with a value for the specified Attribute that is lexically greater than the value of the specified Attribute.
      static Filter greaterThanOrEqualTo​(Attribute attr)
      Select only an input ConnectorObject with a value for the specified Attribute that is lexically greater than or equal to the value of the specified Attribute.
      static Filter lessThan​(Attribute attr)
      Select only an input ConnectorObject with a value for the specified Attribute that is lexically less than the value of the specified Attribute.
      static Filter lessThanOrEqualTo​(Attribute attr)
      Select only an input ConnectorObject with a value for the specified Attribute that is lexically less than or equal to the value of the specified Attribute.
      static Filter not​(Filter filter)
      Logically negate the specified Filter.
      static Filter or​(Collection<Filter> subFilters)
      Creates a new "OR" filter using the provided list of sub-filters.
      static Filter or​(Filter... subFilters)
      Creates a new "OR" filter using the provided list of sub-filters.
      static Filter or​(Filter leftHandSide, Filter rightHandSide)
      Logically "OR" together the two specified instances of Filter.
      static Filter startsWith​(Attribute attr)
      Select only an input ConnectorObject with a value for the specified Attribute that contains as an initial substring the value of the specified Attribute.
    • Method Detail

      • endsWith

        public static Filter endsWith​(Attribute attr)
        Select only an input ConnectorObject with a value for the specified Attribute that contains as a final substring the value of the specified Attribute.

        For example, if the specified Attribute were {"hairColor": "d"},
        this would match any ConnectorObject with a value such as
             {"hairColor": "red"} or
             {"hairColor": "blond"}
        but would not match any ConnectorObject that contains only values such as
             {"hairColor": "blonde"} or
             {"hairColor": "auburn"}.
        This also would not match any ConnectorObject that contains only {"hairColor": null}
        or that lacks the attribute "hairColor".

        Parameters:
        attr - Attribute containing exactly one value to test against each value of the corresponding ConnectorObject attribute.
        Returns:
        an instance of Filter whose accept() method will return true if at least one value of the corresponding attribute of the ConnectorObject contains as its last part the value of the specified Attribute; otherwise false.
      • startsWith

        public static Filter startsWith​(Attribute attr)
        Select only an input ConnectorObject with a value for the specified Attribute that contains as an initial substring the value of the specified Attribute.

        For example, if the specified Attribute were {"hairColor": "b"},
        this would match any ConnectorObject with a value such as
             {"hairColor": "brown"} or
             {"hairColor": "blond"}
        but would not match any ConnectorObject that contains only values such as
             {"hairColor": "red"} or
             {"hairColor": "auburn"}.
        This also would not match any ConnectorObject that contains only {"hairColor": null}
        or that lacks the attribute "hairColor".

        Parameters:
        attr - Attribute containing exactly one value to test against each value of the corresponding ConnectorObject attribute.
        Returns:
        an instance of Filter whose accept() method will return true if at least one value of the corresponding attribute of the ConnectorObject contains as its first part the value of the specified Attribute; otherwise false.
      • contains

        public static Filter contains​(Attribute attr)
        Select only an input ConnectorObject with a value for the specified Attribute that contains as any substring the value of the specified Attribute.

        For example, if the specified Attribute were {"hairColor": "a"},
        this would match any ConnectorObject with a value such as
            {"hairColor": "auburn"} or
            {"hairColor": "gray"}
        but would not match any ConnectorObject that contains only
            {"hairColor": "red"} or
            {"hairColor": "grey"}.
        This also would not match any ConnectorObject that contains only {"hairColor": null}
        or that lacks the attribute "hairColor".

        Parameters:
        attr - Attribute containing exactly one value to test against each value of the corresponding ConnectorObject attribute.
        Returns:
        an instance of Filter whose accept() method will return true if at least one value of the corresponding attribute of the ConnectorObject contains anywhere within it the value of the specified Attribute; otherwise false.
      • equalsIgnoreCase

        public static Filter equalsIgnoreCase​(Attribute attr)
        Select only an input ConnectorObject with a value for the specified Attribute that is equal to, not considering the case the value of the specified Attribute.

        For example, if the specified Attribute were {"hairColor": "brown"},
        this would match any ConnectorObject with a value such as
             {"hairColor": "brown"} or
             {"hairColor": "bRoWn"}
        but would not match any ConnectorObject that contains only values such as
             {"hairColor": "red"} or
             {"hairColor": "auburn"}.
        This also would not match any ConnectorObject that contains only {"hairColor": null}
        or that lacks the attribute "hairColor".

        Parameters:
        attr - Attribute containing exactly one value to test against each value of the corresponding ConnectorObject attribute.
        Returns:
        an instance of Filter whose accept() method will return true if at least one value of the corresponding attribute of the ConnectorObject is equal ignore case the value of the specified Attribute; otherwise false.
      • equalTo

        public static Filter equalTo​(Attribute attr)
        Select only an input ConnectorObject with a value for the specified Attribute that is lexically equal to the value of the specified Attribute.

        For example, if the specified Attribute were {"hairColor": "brown"},
        this would match any ConnectorObject with a value such as
            {"hairColor": "brown"}
        but would not match any ConnectorObject that contains only
            {"hairColor": "brownish-gray"} or
            {"hairColor": "auburn"}.
        This also would not match any ConnectorObject that contains only {"hairColor": null}
        or that lacks the attribute "hairColor".

        NOTE: Lexical comparison of two string values compares the characters of each value, even if the string values could be interpreted as numeric. The values "01" and "1" are unequal lexically, although they would be equivalent arithmetically.

        Two attributes with binary syntax are equal if and only if their constituent bytes match.

        Parameters:
        attr - Attribute containing exactly one value to test against each value of the corresponding ConnectorObject attribute.
        Returns:
        an instance of Filter whose accept() method will return true if at least one value of the corresponding attribute of the ConnectorObject matches lexically the value of the specified Attribute; otherwise false.
      • greaterThanOrEqualTo

        public static Filter greaterThanOrEqualTo​(Attribute attr)
        Select only an input ConnectorObject with a value for the specified Attribute that is lexically greater than or equal to the value of the specified Attribute.

        For example, if the specified Attribute were {"hairColor": "brown"},
        this would match any ConnectorObject with a value such as
            {"hairColor": "brown"} or
            {"hairColor": "brownish-gray"} or
            {"hairColor": "red"}
        but would not match any ConnectorObject that contains only
            {"hairColor": "black"} or
            {"hairColor": "blond"} or
            {"hairColor": "auburn"}.
        This also would not match any ConnectorObject that contains only {"hairColor": null}
        or that lacks the attribute "hairColor".

        NOTE: Lexical comparison of two string values compares the characters of each value, even if the string values could be interpreted as numeric.
        When compared lexically, "99" is greater than "123".
        When compared arithmetically, 99 is less than 123.

        Parameters:
        attr - Attribute containing exactly one value to test against each value of the corresponding ConnectorObject attribute.
        Returns:
        an instance of Filter whose accept() method will return true if at least one value of the corresponding attribute of the ConnectorObject matches or sorts alphabetically after the value of the specified Attribute; otherwise false.
      • lessThanOrEqualTo

        public static Filter lessThanOrEqualTo​(Attribute attr)
        Select only an input ConnectorObject with a value for the specified Attribute that is lexically less than or equal to the value of the specified Attribute.

        For example, if the specified Attribute were {"hairColor": "brown"},
        this would match any ConnectorObject with a value such as
            {"hairColor": "brown"} or
            {"hairColor": "black"} or
            {"hairColor": "blond"} or
            {"hairColor": "auburn"}
        but would not match any ConnectorObject that contains only
            {"hairColor": "brownish-gray"} or
            {"hairColor": "red"}
        This also would not match any ConnectorObject that contains only {"hairColor": null}
        or that lacks the attribute "hairColor".

        NOTE: Lexical comparison of two string values compares the characters of each value, even if the string values could be interpreted as numeric.
        When compared lexically, "99" is greater than "123".
        When compared arithmetically, 99 is less than 123.

        Parameters:
        attr - Attribute containing exactly one value to test against each value of the corresponding ConnectorObject attribute.
        Returns:
        an instance of Filter whose accept() method will return true if at least one value of the corresponding attribute of the ConnectorObject matches or sorts alphabetically before the value of the specified Attribute; otherwise false.
      • lessThan

        public static Filter lessThan​(Attribute attr)
        Select only an input ConnectorObject with a value for the specified Attribute that is lexically less than the value of the specified Attribute.

        For example, if the specified Attribute were {"hairColor": "brown"},
        this would match any ConnectorObject with a value such as
            {"hairColor": "black"} or
            {"hairColor": "blond"} or
            {"hairColor": "auburn"}
        but would not match any ConnectorObject that contains only
            {"hairColor": "brown"} or
            {"hairColor": "brownish-gray"} or
            {"hairColor": "red"}
        This also would not match any ConnectorObject that contains only {"hairColor": null}
        or that lacks the attribute "hairColor".

        NOTE: Lexical comparison of two string values compares the characters of each value, even if the string values could be interpreted as numeric.
        When compared lexically, "99" is greater than "123".
        When compared arithmetically, 99 is less than 123.

        Parameters:
        attr - Attribute containing exactly one value to test against each value of the corresponding ConnectorObject attribute.
        Returns:
        an instance of Filter whose accept() method will return true if at least one value of the corresponding attribute of the ConnectorObject sorts alphabetically before the value of the specified Attribute; otherwise false.
      • greaterThan

        public static Filter greaterThan​(Attribute attr)
        Select only an input ConnectorObject with a value for the specified Attribute that is lexically greater than the value of the specified Attribute.

        For example, if the specified Attribute were {"hairColor": "brown"},
        this would match any ConnectorObject with a value such as
            {"hairColor": "brownish-gray"} or
            {"hairColor": "red"}
        but would not match any ConnectorObject that contains only
            {"hairColor": "brown"} or
            {"hairColor": "black"} or
            {"hairColor": "blond"} or
            {"hairColor": "auburn"}.
        This also would not match any ConnectorObject that contains only {"hairColor": null}
        or that lacks the attribute "hairColor".

        NOTE: Lexical comparison of two string values compares the characters of each value, even if the string values could be interpreted as numeric.
        When compared lexically, "99" is greater than "123".
        When compared arithmetically, 99 is less than 123.

        Parameters:
        attr - Attribute containing exactly one value to test against each value of the corresponding ConnectorObject attribute.
        Returns:
        an instance of Filter whose accept() method will return true if at least one value of the corresponding attribute of the ConnectorObject sorts alphabetically after the value of the specified Attribute; otherwise false.
      • and

        public static Filter and​(Filter leftHandSide,
                                 Filter rightHandSide)
        Logically "ANDs" together the two specified instances of Filter. The resulting conjunct Filter is true if and only if both of the specified filters are true.
        Parameters:
        leftHandSide - left-hand-side filter.
        rightHandSide - right-hand-side filter.
        Returns:
        the result of (leftHandSide && rightHandSide)
      • and

        public static Filter and​(Collection<Filter> subFilters)
        Creates a new "AND" filter using the provided list of sub-filters.

        Creating a new "AND" filter with a null or empty list of sub-filters is equivalent to calling "alwaysTrue".

        Parameters:
        subFilters - The list of sub-filters, may be empty or null.
        Returns:
        The newly created "AND" filter.
      • and

        public static Filter and​(Filter... subFilters)
        Creates a new "AND" filter using the provided list of sub-filters.

        Creating a new "AND" filter with a null or empty list of sub-filters is equivalent to calling "alwaysTrue".

        Parameters:
        subFilters - The list of sub-filters, may be empty or null.
        Returns:
        The newly created "AND" filter.
      • or

        public static Filter or​(Filter leftHandSide,
                                Filter rightHandSide)
        Logically "OR" together the two specified instances of Filter. The resulting disjunct Filter is true if and only if at least one of the specified filters is true.
        Parameters:
        leftHandSide - left-hand-side filter.
        rightHandSide - right-hand-side filter.
        Returns:
        the result of (leftHandSide || rightHandSide)
      • or

        public static Filter or​(Collection<Filter> subFilters)
        Creates a new "OR" filter using the provided list of sub-filters.

        Creating a new "OR" filter with a null or empty list of sub-filters is equivalent to "alwaysTrue".

        Parameters:
        subFilters - The list of sub-filters, may be empty or null.
        Returns:
        The newly created or filter.
      • or

        public static Filter or​(Filter... subFilters)
        Creates a new "OR" filter using the provided list of sub-filters.

        Creating a new "OR" filter with a null or empty list of sub-filters is equivalent to "alwaysTrue".

        Parameters:
        subFilters - The list of sub-filters, may be empty or null.
        Returns:
        The newly created or filter.
      • not

        public static Filter not​(Filter filter)
        Logically negate the specified Filter. The resulting Filter is true if and only if the specified filter is false.
        Parameters:
        filter - the Filter to negate.
        Returns:
        the result of (!filter).
      • containsAllValues

        public static Filter containsAllValues​(Attribute attr)
        Select only an input ConnectorObject with a value for the specified Attribute that contains all the values from the specified Attribute.

        For example, if the specified Attribute were {"hairColor": "brown", "red"},
        this would match any ConnectorObject with values such as

        • {"hairColor": "black", "brown", "red"}
        • {"hairColor": "blond", "brown", "red"}
        • {"hairColor": "auburn", "brown", "red"}
        but would not match any ConnectorObject that contains only
        • {"hairColor": "brown"}
        • {"hairColor": "brownish-gray"}
        • {"hairColor": "red"}
        This also would not match any ConnectorObject that contains only {"hairColor": null}
        or that lacks the attribute "hairColor".

        NOTE: Lexical comparison of two string values compares the characters of each value, even if the string values could be interpreted as numeric.

        Parameters:
        attr - Attribute containing exactly one value to test against each value of the corresponding ConnectorObject attribute.
        Returns:
        an instance of Filter whose accept() method will return true if at least one value of the corresponding attribute of the ConnectorObject sorts alphabetically before the value of the specified Attribute; otherwise false.