Class AbstractConditionalClauseStateObject

java.lang.Object
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractConditionalClauseStateObject
All Implemented Interfaces:
StateObject
Direct Known Subclasses:
HavingClauseStateObject, WhenClauseStateObject, WhereClauseStateObject

public abstract class AbstractConditionalClauseStateObject extends AbstractStateObject
Conditional expressions are composed of other conditional expressions, comparison operations, logical operations, path expressions that evaluate to boolean values, boolean literals, and boolean input parameters. Arithmetic expressions can be used in comparison expressions. Arithmetic expressions are composed of other arithmetic expressions, arithmetic operations, path expressions that evaluate to numeric values, numeric literals, and numeric input parameters. Arithmetic operations use numeric promotion. Standard bracketing () for ordering expression evaluation is supported.

BNF: expression ::= identifier conditional_expression

Since:
2.4
Version:
2.4
See Also:
  • Field Details

    • CONDITIONAL_STATE_OBJECT_PROPERTY

      public static final String CONDITIONAL_STATE_OBJECT_PROPERTY
      Notifies the conditional expression property has changed.
      See Also:
  • Constructor Details

    • AbstractConditionalClauseStateObject

      protected AbstractConditionalClauseStateObject(StateObject parent)
      Creates a new AbstractConditionalClauseStateObject.
      Parameters:
      parent - The parent of this state object, which cannot be null
      Throws:
      NullPointerException - The given parent cannot be null
    • AbstractConditionalClauseStateObject

      protected AbstractConditionalClauseStateObject(StateObject parent, StateObject conditionalStateObject)
      Creates a new AbstractConditionalClauseStateObject.
      Parameters:
      parent - The parent of this state object, which cannot be null
      conditionalStateObject - The StateObject representing the conditional expression
      Throws:
      NullPointerException - The given parent cannot be null
  • Method Details

    • addChildren

      protected void addChildren(List<StateObject> children)
      Description copied from class: AbstractStateObject
      Adds the children of this StateObject to the given list.
      Overrides:
      addChildren in class AbstractStateObject
      Parameters:
      children - The list used to store the children
    • andParse

      public AndExpressionStateObject andParse(String jpqlFragment)
      Parses the given JPQL fragment as the right side of an AND expression. The current conditional expression will become the left side of the AND expression.
      Parameters:
      jpqlFragment - The portion of the query representing the right side of the AND expression
      Returns:
      The newly created AndExpressionStateObject
    • getBuilder

      Creates and returns a new IConditionalExpressionStateObjectBuilder that can be used to programmatically create a conditional expression and once the expression is complete, IConditionalExpressionStateObjectBuilder.commit() will push the StateObject representation of that expression as this clause's conditional expression.
      Returns:
      A new builder that can be used to quickly create a conditional expression
    • getConditional

      public StateObject getConditional()
      Returns the state object representing the composition of the conditional expressions.
      Returns:
      The actual conditional expression
    • getIdentifier

      public abstract String getIdentifier()
      Returns the JPQL identifier of this clause.
      Returns:
      The JPQL identifier of this conditional clause
    • hasConditional

      public boolean hasConditional()
      Determines whether the StateObject representing the conditional expression is present or not.
      Returns:
      true if the conditional expression is not null; false otherwise
    • isEquivalent

      public boolean isEquivalent(StateObject stateObject)
      Description copied from interface: StateObject
      Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.
      Specified by:
      isEquivalent in interface StateObject
      Overrides:
      isEquivalent in class AbstractStateObject
      Parameters:
      stateObject - The StateObject to compare its content to this one
      Returns:
      true if both object are equivalent; false otherwise
    • orParse

      public OrExpressionStateObject orParse(String jpqlFragment)
      Parses the given JPQL fragment as the right side of an OR expression. The current conditional expression will become the left side of the OR expression.
      Parameters:
      jpqlFragment - The portion of the query representing the right side of the OR expression
      Returns:
      The newly created OrExpressionStateObject
    • parse

      public void parse(String jpqlFragment)
      Parses the given JPQL fragment, which represents a conditional expression, and creates the StateObject.
      Parameters:
      jpqlFragment - The portion of the query representing a conditional expression
    • setConditional

      public void setConditional(StateObject conditionalStateObject)
      Sets the given StateObject to be the conditional expression of this clause.
      Parameters:
      conditionalStateObject - The new StateObject representing the conditional expression
    • shouldEncapsulateORExpression

      protected boolean shouldEncapsulateORExpression(StateObject stateObject)
    • toTextInternal

      protected void toTextInternal(Appendable writer) throws IOException
      Description copied from class: AbstractStateObject
      Prints out a string representation of this StateObject, which should not be used to define a true string representation of a JPQL query but should be used for debugging purposes.
      Specified by:
      toTextInternal in class AbstractStateObject
      Parameters:
      writer - The writer used to print out the string representation
      Throws:
      IOException - This should never happens, it is only required because Appendable is used instead of any concrete class