Module gg.xp.xivapi

Class SearchFilters

java.lang.Object
gg.xp.xivapi.filters.SearchFilters

public final class SearchFilters extends Object
Collection of methods useful for constructing search filters.

All objects returned by this class are immutable. They can safely be re-used without making defensive copies.

Some search filters will intelligently "collapse" - for example not(not(foo)) will collapse down to foo, and or(or(a, b), c) will collapse to or(a, b, c).

Some methods in here also have equivalents on the SearchFilter interface itself, mainly so that you can use Groovy operator overloads seamlessly, e.g. a | b instead of or(a, b).

  • Method Details

    • of

      public static SearchFilter of(String filterValue)
      Search filter from a verbatim string. Must already be formatted correctly and have double-quotes and backslashes already escaped, but should not be URL-escaped.
      Parameters:
      filterValue - The search string.
      Returns:
      The search filter consisting of that literal string.
    • or

      public static SearchFilter or(String... filters)
      Combine multiple filters in an OR fashion.
      Parameters:
      filters - The raw string filters. Must already be formatted correctly minus URL escaping (see of(String).
      Returns:
      A filter representing the logical OR of the constituent filters.
    • or

      public static SearchFilter or(List<SearchFilter> filters)
      Combine multiple filters in an OR fashion.
      Parameters:
      filters - The raw string filters. Must already be formatted correctly minus URL escaping (see of(String).
      Returns:
      A filter representing the logical OR of the constituent filters.
    • or

      public static SearchFilter or(SearchFilter... filters)
      Combine multiple filters in an OR fashion.
      Parameters:
      filters - The filters.
      Returns:
      A filter representing the logical OR of the constituent filters.
    • and

      public static SearchFilter and(String... filters)
      Combine multiple filters in an AND fashion.
      Parameters:
      filters - The raw string filters. Must already be formatted correctly minus URL escaping (see of(String).
      Returns:
      A filter representing the logical AND of the constituent filters.
    • and

      public static SearchFilter and(List<SearchFilter> filters)
      Combine multiple filters in an AND fashion.
      Parameters:
      filters - The raw string filters. Must already be formatted correctly minus URL escaping (see of(String).
      Returns:
      A filter representing the logical AND of the constituent filters.
    • and

      public static SearchFilter and(SearchFilter... filters)
      Combine multiple filters in an AND fashion.
      Parameters:
      filters - The raw string filters.
      Returns:
      A filter representing the logical AND of the constituent filters.
    • not

      public static SearchFilter not(SearchFilter filter)
      Logically invert a filter.
      Parameters:
      filter - The filter to invert.
      Returns:
      The filter representing the logical inverse of the input.
    • binary

      public static SearchFilter binary(String field, String operator, Object value)
      Create a filter using a binary operator.
      Parameters:
      field - The field on which to operate.
      operator - The operator to apply.
      value - The value. String values will be quoted and escaped automatically.
      Returns:
      The binary filter.
    • eq

      public static SearchFilter eq(String field, Object value)
      Create a binary(String, String, Object) filter using the '=' (equals) operator.
      Parameters:
      field - The field.
      value - The expected value.
      Returns:
      The filter.
    • isTrue

      public static SearchFilter isTrue(String field)
      Create a filter for a boolean value being true.
      Parameters:
      field - The field on which to expect truth.
      Returns:
      The filter.
    • isFalse

      public static SearchFilter isFalse(String field)
      Create a filter for a boolean value being false.
      Parameters:
      field - The field on which to expect falsity.
      Returns:
      The filter.
    • gte

      public static SearchFilter gte(String field, Number value)
      Create a binary(String, String, Object) filter using the '>=' (greater than or equal to) operator.
      Parameters:
      field - The field.
      value - The comparison value.
      Returns:
      The filter.
    • lte

      public static SearchFilter lte(String field, Number value)
      Create a binary(String, String, Object) filter using the '<=' (less than or equal to) operator.
      Parameters:
      field - The field.
      value - The comparison value.
      Returns:
      The filter.
    • gt

      public static SearchFilter gt(String field, Number value)
      Create a binary(String, String, Object) filter using the '>' (strictly greater than) operator.
      Parameters:
      field - The field.
      value - The comparison value.
      Returns:
      The filter.
    • lt

      public static SearchFilter lt(String field, Number value)
      Create a binary(String, String, Object) filter using the '<' (strictly less than) operator.
      Parameters:
      field - The field.
      value - The comparison value.
      Returns:
      The filter.
    • strPart

      public static SearchFilter strPart(String field, String value)
      Create a binary(String, String, Object) filter using the '~' (string contains) operator.
      Parameters:
      field - The field.
      value - The partial string to search for.
      Returns:
      The filter.
    • any

      public static String any(String field)
      Modifies a field name with the '[]' modifier. This should be used with an array field, to expect that any index matches the filter to which this is applied.
      Parameters:
      field - The field to match.
      Returns:
      A String representing the field name with the "any index" modifier applied.
    • index

      public static String index(String field, int index)
      Modifies a field name with the '[index]' modifier. This should be used with an array field, to expect that a specific index matches the filter to which this is applied.
      Parameters:
      field - The field to match.
      Returns:
      A String representing the field name with the "specific index" modifier applied.