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
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringNotifies the conditional expression property has changed. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a newAbstractConditionalClauseStateObject.protectedAbstractConditionalClauseStateObject(StateObject parent, StateObject conditionalStateObject) Creates a newAbstractConditionalClauseStateObject. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddChildren(List<StateObject> children) Adds the children of thisStateObjectto the given list.Parses the given JPQL fragment as the right side of anANDexpression.Creates and returns a newIConditionalExpressionStateObjectBuilderthat can be used to programmatically create a conditional expression and once the expression is complete,IConditionalExpressionStateObjectBuilder.commit()will push theStateObjectrepresentation of that expression as this clause's conditional expression.Returns the state object representing the composition of the conditional expressions.abstract StringReturns the JPQL identifier of this clause.booleanDetermines whether theStateObjectrepresenting the conditional expression is present or not.booleanisEquivalent(StateObject stateObject) Determines whether the givenStateObjectis equivalent to this one, i.e.Parses the given JPQL fragment as the right side of anORexpression.voidParses the given JPQL fragment, which represents a conditional expression, and creates theStateObject.voidsetConditional(StateObject conditionalStateObject) Sets the givenStateObjectto be the conditional expression of this clause.protected booleanshouldEncapsulateORExpression(StateObject stateObject) protected voidtoTextInternal(Appendable writer) Prints out a string representation of thisStateObject, which should not be used to define atruestring representation of a JPQL query but should be used for debugging purposes.Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
acceptUnknownVisitor, acceptUnknownVisitor, addProblems, addPropertyChangeListener, areEquivalent, buildProblem, buildProblem, buildStateObject, buildStateObjects, checkParent, children, decorate, equals, findIdentificationVariable, firePropertyChanged, getChangeSupport, getDeclaration, getDecorator, getExpression, getGrammar, getManagedTypeProvider, getParent, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, initialize, isDecorated, parent, parent, parent, removePropertyChangeListener, setExpression, setParent, toString, toString, toStringInternal, toStringItems, toTextMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject
accept
-
Field Details
-
CONDITIONAL_STATE_OBJECT_PROPERTY
Notifies the conditional expression property has changed.- See Also:
-
-
Constructor Details
-
AbstractConditionalClauseStateObject
Creates a newAbstractConditionalClauseStateObject.- Parameters:
parent- The parent of this state object, which cannot benull- Throws:
NullPointerException- The given parent cannot benull
-
AbstractConditionalClauseStateObject
protected AbstractConditionalClauseStateObject(StateObject parent, StateObject conditionalStateObject) Creates a newAbstractConditionalClauseStateObject.- Parameters:
parent- The parent of this state object, which cannot benullconditionalStateObject- TheStateObjectrepresenting the conditional expression- Throws:
NullPointerException- The given parent cannot benull
-
-
Method Details
-
addChildren
Description copied from class:AbstractStateObjectAdds the children of thisStateObjectto the given list.- Overrides:
addChildrenin classAbstractStateObject- Parameters:
children- The list used to store the children
-
andParse
Parses the given JPQL fragment as the right side of anANDexpression. The current conditional expression will become the left side of theANDexpression.- Parameters:
jpqlFragment- The portion of the query representing the right side of theANDexpression- Returns:
- The newly created
AndExpressionStateObject
-
getBuilder
Creates and returns a newIConditionalExpressionStateObjectBuilderthat can be used to programmatically create a conditional expression and once the expression is complete,IConditionalExpressionStateObjectBuilder.commit()will push theStateObjectrepresentation of that expression as this clause's conditional expression.- Returns:
- A new builder that can be used to quickly create a conditional expression
-
getConditional
Returns the state object representing the composition of the conditional expressions.- Returns:
- The actual conditional expression
-
getIdentifier
Returns the JPQL identifier of this clause.- Returns:
- The JPQL identifier of this conditional clause
-
hasConditional
public boolean hasConditional()Determines whether theStateObjectrepresenting the conditional expression is present or not.- Returns:
trueif the conditional expression is notnull;falseotherwise
-
isEquivalent
Description copied from interface:StateObjectDetermines whether the givenStateObjectis equivalent to this one, i.e. the information of bothStateObjectis the same.- Specified by:
isEquivalentin interfaceStateObject- Overrides:
isEquivalentin classAbstractStateObject- Parameters:
stateObject- TheStateObjectto compare its content to this one- Returns:
trueif both object are equivalent;falseotherwise
-
orParse
Parses the given JPQL fragment as the right side of anORexpression. The current conditional expression will become the left side of theORexpression.- Parameters:
jpqlFragment- The portion of the query representing the right side of theORexpression- Returns:
- The newly created
OrExpressionStateObject
-
parse
Parses the given JPQL fragment, which represents a conditional expression, and creates theStateObject.- Parameters:
jpqlFragment- The portion of the query representing a conditional expression
-
setConditional
Sets the givenStateObjectto be the conditional expression of this clause.- Parameters:
conditionalStateObject- The newStateObjectrepresenting the conditional expression
-
shouldEncapsulateORExpression
-
toTextInternal
Description copied from class:AbstractStateObjectPrints out a string representation of thisStateObject, which should not be used to define atruestring representation of a JPQL query but should be used for debugging purposes.- Specified by:
toTextInternalin classAbstractStateObject- Parameters:
writer- The writer used to print out the string representation- Throws:
IOException- This should never happens, it is only required becauseAppendableis used instead of any concrete class
-