Class CompoundExpressionStateObject

java.lang.Object
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
org.eclipse.persistence.jpa.jpql.tools.model.query.CompoundExpressionStateObject
All Implemented Interfaces:
StateObject
Direct Known Subclasses:
ArithmeticExpressionStateObject, ComparisonExpressionStateObject, LogicalExpressionStateObject

public abstract class CompoundExpressionStateObject extends AbstractStateObject
A compound StateObject has a left and right expressions combined by an identifier.

BNF: expression ::= left_expression <identifier> right_expression

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

    • LEFT_STATE_OBJECT_PROPERTY

      public static final String LEFT_STATE_OBJECT_PROPERTY
      Notifies the left state object property has changed.
      See Also:
    • RIGHT_STATE_OBJECT_PROPERTY

      public static final String RIGHT_STATE_OBJECT_PROPERTY
      Notifies the right state object property has changed.
      See Also:
  • Constructor Details

    • CompoundExpressionStateObject

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

      protected CompoundExpressionStateObject(StateObject parent, StateObject leftStateObject, StateObject rightStateObject)
      Creates a new ArithmeticExpressionStateObject.
      Parameters:
      parent - The parent of this state object, which cannot be null
      leftStateObject - The StateObject representing the left expression
      rightStateObject - The StateObject representing the right expression
      Throws:
      NullPointerException - The given parent cannot be null
    • CompoundExpressionStateObject

      protected CompoundExpressionStateObject(StateObject parent, String leftJpqlFragment, String rightJpqlFragment)
      Creates a new ArithmeticExpressionStateObject.
      Parameters:
      parent - The parent of this state object, which cannot be null
      leftJpqlFragment - The string representation of the left expression to parse and to convert into a StateObject
      rightJpqlFragment - The string representation of the right expression to parse and to convert into a StateObject
      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
    • getExpression

      public CompoundExpression getExpression()
      Description copied from interface: StateObject
      Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.
      Specified by:
      getExpression in interface StateObject
      Overrides:
      getExpression in class AbstractStateObject
      Returns:
      The parsed object when a JPQL query is parsed and converted into a StateObject or null when the JPQL query is manually created (i.e. not from a string)
    • getIdentifier

      public abstract String getIdentifier()
      Returns the identifier joining the two StateObjects.
      Returns:
      The JPQL identifier join two expressions
    • getLeft

      public StateObject getLeft()
      Returns the StateObject that represents the left expression.
      Returns:
      The StateObject representing the left expression
    • getLeftQueryBNFId

      protected abstract String getLeftQueryBNFId()
      Returns the unique identifier of the BNF that will be used to parse a JPQL fragment as the left side of the expression.
      Returns:
      The query BNF ID for the left side of the expression
    • getRight

      public StateObject getRight()
      Returns the StateObject that represents the right expression.
      Returns:
      The StateObject representing the right expression
    • getRightQueryBNFId

      protected abstract String getRightQueryBNFId()
      Returns the unique identifier of the BNF that will be used to parse a JPQL fragment as the right side of the expression.
      Returns:
      The query BNF ID for the right side of the expression
    • hasLeft

      public boolean hasLeft()
      Determines whether there is a StateObject that represents the left expression.
      Returns:
      true if there is a left StateObject; false if it is null
    • hasRight

      public boolean hasRight()
      Determines whether there is a StateObject that represents the right expression.
      Returns:
      true if there is a right StateObject; false if it is null
    • 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
    • parseLeft

      public void parseLeft(String jpqlFragment)
      Parses the given JPQL fragment and update the left side of the compound expression.
      Parameters:
      jpqlFragment - The portion of the query to become the left side of the compound expression
    • parseRight

      public void parseRight(String jpqlFragment)
      Parses the given JPQL fragment and update the right side of the compound expression.
      Parameters:
      jpqlFragment - The portion of the query to become the right side of the compound expression
    • setLeft

      public void setLeft(StateObject leftStateObject)
      Sets the left StateObject to become the given object.
      Parameters:
      leftStateObject - The StateObject representing the left expression
    • setRight

      public void setRight(StateObject rightStateObject)
      Sets the right StateObject to become the given object.
      Parameters:
      rightStateObject - The StateObject representing the right expression
    • 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