Class SearchOperatorSet

java.lang.Object
org.apache.juneau.commons.beanquery.SearchOperatorSet

public final class SearchOperatorSet extends Object
An immutable, ordered collection of SearchOperators that governs which $-operators the parser recognizes.

standard() is the built-in set (the confirmed operators with their arity and per-type applicability). Applications extend it with with(SearchOperator) (add a custom operator to a copy) or build a bespoke set with of(SearchOperator...). A context uses one set as its default and may hold a per-column map; a per-column set replaces the default for that column rather than merging with it.

Juneau uses the spellings $prefix and $blank as first-class names; there are deliberately no $starts/$empty aliases.

Case-insensitive names

Lookup (get(String), contains(String), without(String)) is case-insensitive: $EQ, $Eq and $eq all resolve to the same operator. of(SearchOperator...) rejects two operators whose names differ only in case; with(SearchOperator) replaces a same-name-ignoring-case operator, the same way it replaces an exact-name one. operators() and get(String) always expose the operator's own canonical (registered) name, never the casing a caller looked it up with.

Example:

// Hide $regex unless a caller opts in. SearchOperatorSet restricted = SearchOperatorSet.standard().without("$regex"); // $EQ resolves to the same operator as $eq. SearchOperator eq = restricted.get("$EQ");

Since:
10.0.0
  • Method Details

    • standard

      public static SearchOperatorSet standard()
      The built-in operator set.
      Returns:
      The standard set, never null.
    • of

      public static SearchOperatorSet of(SearchOperator... operators)
      Builds a set from exactly the specified operators (no built-ins are implied).
      Parameters:
      operators - The operators, in the order to expose them. Must not be null; names must be unique ignoring case.
      Returns:
      A new set.
    • with

      Returns a copy of this set with the specified operator added, replacing a same-name-ignoring-case operator if one is already present.
      Parameters:
      op - The operator to add. Must not be null.
      Returns:
      A new set; this set is unchanged.
    • without

      Returns a copy of this set without the named operator.
      Parameters:
      name - The operator name (for example "$regex"), matched ignoring case. Can be null.
      Returns:
      A new set, or this set if it has no operator with that name.
    • get

      public SearchOperator get(String name)
      Looks up an operator by name, ignoring case.
      Parameters:
      name - The operator name, including the leading $ (e.g. "$eq" or "$EQ"). Can be null.
      Returns:
      The operator (with its canonical, registered-case name), or null if not in this set.
    • contains

      public boolean contains(String name)
      Whether this set contains an operator with the specified name, ignoring case.
      Parameters:
      name - The operator name. Can be null.
      Returns:
      true if present.
    • operators

      All operators in this set, in canonical order.
      Returns:
      An unmodifiable list.
    • forType

      The operators in this set offered for the specified value type, including the combinators (which apply to every type).
      Parameters:
      type - The column value type. Can be null (yields an empty list).
      Returns:
      An unmodifiable list of applicable operators, in canonical order.