Class SearchOperator.Builder

java.lang.Object
org.apache.juneau.commons.beanquery.SearchOperator.Builder
Enclosing class:
SearchOperator

public static final class SearchOperator.Builder extends Object
Builder for SearchOperator. See the class Javadoc for an example. Start one with SearchOperator.create(String, String) or SearchOperator.copy().
  • Method Details

    • name

      Sets the operator name, including the leading $ (e.g. "$near").
      Parameters:
      value - The operator name.
      Returns:
      This object.
    • help

      Sets the popup help text.
      Parameters:
      value - The help text.
      Returns:
      This object.
    • minArgs

      public SearchOperator.Builder minArgs(int value)
      Sets the minimum argument count (inclusive).
      Parameters:
      value - The minimum number of arguments.
      Returns:
      This object.
    • maxArgs

      public SearchOperator.Builder maxArgs(int value)
      Sets the maximum argument count (inclusive), or -1 for unbounded.
      Parameters:
      value - The maximum number of arguments, or -1 for no upper bound.
      Returns:
      This object.
    • types

      Sets the value types this operator applies to.
      Parameters:
      value - The applicable types, or none to mean "applies to all types".
      Returns:
      This object.
    • predicate

      Attaches the in-memory evaluator for this (custom) operator.
      Parameters:
      value - The predicate the in-memory context calls for this operator. Can be null to leave it with no in-memory evaluator.
      Returns:
      This object.
    • typedArgs

      public SearchOperator.Builder typedArgs(boolean value)
      Opts this (custom) operator's SQL renderer into typed argument values.

      Built-in value operators ($eq/$ne/$in/$gt/$gte/$lt/ $lte/$between) always receive typed arguments from QueryResolver. For a custom operator, this flag controls only its SQL renderer: when true, a SQL context passes SearchExpression.typedArgs() instead of SearchExpression.literalArgs(). The in-memory SearchPredicate always receives literal strings regardless of this flag.

      Parameters:
      value - true for the SQL renderer to receive typed arguments.
      Returns:
      This object.
    • extension

      public <X> SearchOperator.Builder extension(Class<X> type, X value)
      Attaches a typed extension, keyed by its own Class.

      This is how a downstream module (for example juneau-beanquery-sql's SQL renderer) attaches its own metadata to a custom operator without this module (commons) ever depending on that module's types (design ยง5.3). Retrieve it later with SearchOperator.extension(Class).

      Type Parameters:
      X - The extension type.
      Parameters:
      type - The extension's class, used as the lookup key. Must not be null.
      value - The extension value. Can be null.
      Returns:
      This object.
    • build

      Builds the immutable SearchOperator.
      Returns:
      A new, immutable operator.
      Throws:
      IllegalArgumentException - If name is null or blank, help is null or blank on a custom operator, minArgs is negative, maxArgs is neither -1 nor >= minArgs, or this builder was seeded from copy() of a built-in operator and name has been changed since.