Class BeanQueryContext.Builder<T,SELF extends BeanQueryContext.Builder<T,SELF>>

java.lang.Object
org.apache.juneau.commons.beanquery.BeanQueryContext.Builder<T,SELF>
Type Parameters:
T - The row type.
SELF - The concrete builder type, returned by every setter.
Direct Known Subclasses:
InMemoryBeanQueryContext.Builder, SqlBeanQueryContext.Builder
Enclosing class:
BeanQueryContext<T>

public abstract static class BeanQueryContext.Builder<T,SELF extends BeanQueryContext.Builder<T,SELF>> extends Object
The settings every engine's context builder shares.

Single-argument problems throw IllegalArgumentException from the setter. Missing or conflicting settings throw IllegalStateException from build().

  • Constructor Details

    • Builder

      protected Builder()
      Constructor for a new, empty builder.
    • Builder

      protected Builder(BeanQueryContext<T> copyFrom)
      Copy constructor.
      Parameters:
      copyFrom - The context whose settings are copied. Must not be null.
  • Method Details

    • self

      protected final SELF self()
      Returns this builder as its concrete type.
      Returns:
      This object.
    • column

      public SELF column(String name, SearchType type)
      Declares a column, or changes the type of a declared one (keeping its position).
      Parameters:
      name - The column name. Must not be blank.
      type - The column's value type. Must not be null.
      Returns:
      This object.
    • columns

      public SELF columns(String... names)
      Keeps only the specified declared columns, in the specified order.
      Parameters:
      names - The column names. Each must already be declared.
      Returns:
      This object.
    • exclude

      public SELF exclude(String... names)
      Removes declared columns (and any operator override on them).
      Parameters:
      names - The column names. Each must be declared.
      Returns:
      This object.
    • declared

      protected final String declared(String name)
      Checks that a column is declared.
      Parameters:
      name - The column name.
      Returns:
      The same name.
      Throws:
      IllegalArgumentException - If the column is not declared.
    • operators

      Sets the default operator set (for columns without an override). Default: SearchOperatorSet.standard().
      Parameters:
      value - The operator set. Must not be null.
      Returns:
      This object.
    • columnOperators

      public SELF columnOperators(String column, SearchOperatorSet value)
      Replaces the operator set for one declared column.
      Parameters:
      column - The column name. Must be declared.
      value - The operator set. Must not be null.
      Returns:
      This object.
    • allowRegex

      public SELF allowRegex(boolean value)
      Allows the $regex operator. Default: true; allowRegex(false) disables it.
      Parameters:
      value - The new value.
      Returns:
      This object.
    • regexTimeout

      public SELF regexTimeout(Duration value)
      Sets the time budget for all $regex matching in one session call. Default: 50 ms.
      Parameters:
      value - The budget. Must be positive.
      Returns:
      This object.
    • countPolicy

      public SELF countPolicy(CountPolicy value)
      Sets which counts find / findValues compute. Default: CountPolicy.IF_REQUESTED.
      Parameters:
      value - The policy. Must not be null.
      Returns:
      This object.
    • defaultLimit

      public SELF defaultLimit(int value)
      Sets the limit used when a query has none. Default: 100.
      Parameters:
      value - The limit. Must be positive.
      Returns:
      This object.
    • maxLimit

      public SELF maxLimit(Integer value)
      Sets the largest limit a query can ask for; larger limits and limit=-1 are clamped to it. Default: 1000.

      If this builder's defaultLimit was never explicitly set (it is still QuerySettings's own baseline default, or — for a builder from BeanQueryContext.copy() — still whatever the source context had), narrowing maxLimit below it auto-narrows defaultLimit to match, rather than leaving the two in conflict. An explicitly-chosen defaultLimit is never silently changed by this setter — a resulting conflict is left for build() to reject.

      Parameters:
      value - The cap, or null for no cap. Must be positive if set.
      Returns:
      This object.
    • maxSearchClauses

      public SELF maxSearchClauses(int value)
      Sets the largest number of search clauses. Default: 64.
      Parameters:
      value - The cap. Must be positive.
      Returns:
      This object.
    • maxSortKeys

      public SELF maxSortKeys(int value)
      Sets the largest number of sort keys. Default: 8.
      Parameters:
      value - The cap. Must be positive.
      Returns:
      This object.
    • maxSearchLength

      public SELF maxSearchLength(int value)
      Sets the longest search, sort, view or opts string. Default: 4096.
      Parameters:
      value - The cap. Must be positive.
      Returns:
      This object.
    • maxExpressionDepth

      public SELF maxExpressionDepth(int value)
      Sets the deepest allowed expression nesting. Default: 16.
      Parameters:
      value - The cap. Must be positive.
      Returns:
      This object.
    • build

      public abstract BeanQueryContext<T> build()
      Builds the immutable context.
      Returns:
      A new context.
      Throws:
      IllegalStateException - If a required setting is missing or two settings conflict.