Class BeanQuery.GroupBuilder

java.lang.Object
org.apache.juneau.commons.beanquery.BeanQuery.GroupBuilder
Enclosing class:
BeanQuery

public static final class BeanQuery.GroupBuilder extends Object
A group of cross-column conditions built with BeanQuery.Builder.or(Consumer), BeanQuery.Builder.and(Consumer), or BeanQuery.Builder.not(Consumer).

Exposes the same condition methods as BeanQuery.Builder, minus paging/view/sort/opts, since a group only ever contributes conditions to its enclosing level.

Example:

BeanQuery.create().or(g -> g.eq("a", 1).eq("b", 2)); // -> "$or(a=$eq(\"1\"),b=$eq(\"2\"))"

Since:
10.0.0
  • Method Details

    • eq

      public BeanQuery.GroupBuilder eq(String column, Object value)
      Adds an equals condition.
      Parameters:
      column - The column name.
      value - The value to compare against.
      Returns:
      This object.
    • ne

      public BeanQuery.GroupBuilder ne(String column, Object... values)
      Adds a not-equals condition, true if the column matches none of values.
      Parameters:
      column - The column name.
      values - The values to compare against.
      Returns:
      This object.
    • in

      public BeanQuery.GroupBuilder in(String column, Object... values)
      Adds an in-list condition, true if the column matches any of values.
      Parameters:
      column - The column name.
      values - The values to compare against.
      Returns:
      This object.
    • contains

      public BeanQuery.GroupBuilder contains(String column, Object value)
      Adds a substring-match condition.
      Parameters:
      column - The column name.
      value - The substring to search for.
      Returns:
      This object.
    • prefix

      public BeanQuery.GroupBuilder prefix(String column, Object value)
      Adds a prefix-match condition.
      Parameters:
      column - The column name.
      value - The prefix to match.
      Returns:
      This object.
    • blank

      Adds a blank-value condition.
      Parameters:
      column - The column name.
      Returns:
      This object.
    • notBlank

      Adds a not-blank condition.
      Parameters:
      column - The column name.
      Returns:
      This object.
    • gt

      public BeanQuery.GroupBuilder gt(String column, Object value)
      Adds a greater-than condition.
      Parameters:
      column - The column name.
      value - The value to compare against.
      Returns:
      This object.
    • gte

      public BeanQuery.GroupBuilder gte(String column, Object value)
      Adds a greater-than-or-equal condition.
      Parameters:
      column - The column name.
      value - The value to compare against.
      Returns:
      This object.
    • lt

      public BeanQuery.GroupBuilder lt(String column, Object value)
      Adds a less-than condition.
      Parameters:
      column - The column name.
      value - The value to compare against.
      Returns:
      This object.
    • lte

      public BeanQuery.GroupBuilder lte(String column, Object value)
      Adds a less-than-or-equal condition.
      Parameters:
      column - The column name.
      value - The value to compare against.
      Returns:
      This object.
    • between

      public BeanQuery.GroupBuilder between(String column, Object lower, Object upper)
      Adds a between condition, inclusive of both bounds.
      Parameters:
      column - The column name.
      lower - The lower bound.
      upper - The upper bound.
      Returns:
      This object.
    • regex

      public BeanQuery.GroupBuilder regex(String column, String pattern)
      Adds a regex-match condition. The session still rejects this unless regex search is enabled (context/session design D7).
      Parameters:
      column - The column name.
      pattern - The regular expression.
      Returns:
      This object.
    • regex

      public BeanQuery.GroupBuilder regex(String column, String pattern, String flags)
      Adds a regex-match condition with flags. The session still rejects this unless regex search is enabled (context/session design D7).
      Parameters:
      column - The column name.
      pattern - The regular expression.
      flags - The regex flags (engine-specific, e.g. "i" for case-insensitive).
      Returns:
      This object.
    • op

      public BeanQuery.GroupBuilder op(String column, String name, Object... values)
      Escape hatch for an operator not exposed by a dedicated method above. name must start with "$".
      Parameters:
      column - The column name.
      name - The operator name, starting with "$".
      values - The operator's arguments.
      Returns:
      This object.
    • search

      public BeanQuery.GroupBuilder search(String column, String expression)
      Escape hatch for a raw, already-formatted expression. Unlike every other condition method, the expression is used as-is and is not quoted.
      Parameters:
      column - The column name.
      expression - The raw expression, e.g. "$eq(\"bob\")".
      Returns:
      This object.
    • or

      Adds a cross-column $or(...) group. A block that adds no items adds nothing; a block that adds exactly one item emits that item unwrapped (no $or(...) wrapper).
      Parameters:
      block - Populates the group's conditions on a fresh BeanQuery.GroupBuilder.
      Returns:
      This object.
    • and

      Adds a cross-column $and(...) group. A block that adds no items adds nothing; a block that adds exactly one item emits that item unwrapped (no $and(...) wrapper).
      Parameters:
      block - Populates the group's conditions on a fresh BeanQuery.GroupBuilder.
      Returns:
      This object.
    • not

      Adds a $not(...) group. The block must add exactly one item (a leaf or a nested group); any other count throws IllegalArgumentException.
      Parameters:
      block - Populates the single negated condition on a fresh BeanQuery.GroupBuilder.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - If the block adds a number of items other than exactly one.