Class InCondition

java.lang.Object
org.tentackle.dbms.dsl.InCondition
All Implemented Interfaces:
Condition, SqlElement

public class InCondition extends Object implements Condition
An expression tested to be one of a set of values or sub-select rows.

An empty set of values is rendered as a condition that is never true (always true if negated), which is what applications expect when they build the value set dynamically.

Author:
harald
  • Constructor Details

    • InCondition

      public InCondition(Expression<?> expression, Collection<? extends Expression<?>> values, boolean negated)
      Creates a condition testing an expression against a set of values.
      Parameters:
      expression - the tested expression
      values - the values, may be empty
      negated - true for NOT IN, false for IN
    • InCondition

      public InCondition(Expression<?> expression, Select select, boolean negated)
      Creates a condition testing an expression against the rows of a sub-select.
      Parameters:
      expression - the tested expression
      select - the sub-select returning a single column
      negated - true for NOT IN, false for IN
  • Method Details

    • getExpression

      public Expression<?> getExpression()
      Gets the tested expression.
      Returns:
      the expression
    • getValues

      public List<Expression<?>> getValues()
      Gets the values.
      Returns:
      the unmodifiable list of values, null if this condition refers to a sub-select
    • getSelect

      public Select getSelect()
      Gets the sub-select.
      Returns:
      the sub-select, null if this condition refers to a list of values
    • isNegated

      public boolean isNegated()
      Returns whether the expression is tested not to be one of the values.
      Returns:
      true for NOT IN, false for IN
    • render

      public void render(RenderContext context)
      Description copied from interface: SqlElement
      Renders this element into the given context.
      Specified by:
      render in interface SqlElement
      Parameters:
      context - the render context