Class WhenClauseStateObject
java.lang.Object
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractConditionalClauseStateObject
org.eclipse.persistence.jpa.jpql.tools.model.query.WhenClauseStateObject
- All Implemented Interfaces:
StateObject
A
or
WHEN predicate is used to calculate a condition and when it's true, its
THEN will be executed.
BNF: when_clause ::= WHEN conditional_expression THEN scalar_expression
BNF: simple_when_clause ::= WHEN scalar_expression THEN scalar_expression
- Since:
- 2.4
- Version:
- 2.4
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringNotify theStateObjectrepresenting the scalar expression that follows theTHENidentifier has changed.Fields inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractConditionalClauseStateObject
CONDITIONAL_STATE_OBJECT_PROPERTY -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newWhenClauseStateObject.WhenClauseStateObject(CaseExpressionStateObject parent, String whenJpqlFragment, String thenJpqlFragment) Creates a newWhenClauseStateObject.WhenClauseStateObject(CaseExpressionStateObject parent, StateObject whenStateObject, StateObject thenStateObject) Creates a newWhenClauseStateObject. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(StateObjectVisitor visitor) Visits thisStateObjectby the givenvisitor.protected voidaddChildren(List<StateObject> children) Adds the children of thisStateObjectto the given list.protected voidaddProblems(List<Problem> problems) Adds to the given list the problems that were found with the current state of thisStateObject, which means there are validation issues.Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.Returns the JPQL identifier of this clause.Returns the parent of thisStateObject.getThen()Returns theStateObjectrepresenting the scalar expression that is following theTHENidentifier.booleanhasThen()Determines whether theStateObjectrepresenting the scalar expression is present.booleanisEquivalent(StateObject stateObject) Determines whether the givenStateObjectis equivalent to this one, i.e.voidParses the given JPQL fragment, which will represent theTHENexpression.voidParses the given JPQL fragment, which will represent theWHENclause.voidsetExpression(WhenClause expression) Keeps a reference of theparsed objectobject, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects.voidsetThen(StateObject thenStateObject) Sets the scalar expression to be the givenStateObject.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.AbstractConditionalClauseStateObject
andParse, getBuilder, getConditional, hasConditional, orParse, parse, setConditional, shouldEncapsulateORExpressionMethods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
acceptUnknownVisitor, acceptUnknownVisitor, addPropertyChangeListener, areEquivalent, buildProblem, buildProblem, buildStateObject, buildStateObjects, checkParent, children, decorate, equals, findIdentificationVariable, firePropertyChanged, getChangeSupport, getDeclaration, getDecorator, getGrammar, getManagedTypeProvider, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, initialize, isDecorated, parent, parent, parent, removePropertyChangeListener, setExpression, setParent, toString, toString, toStringInternal, toStringItems, toText
-
Field Details
-
THEN_STATE_OBJECT_PROPERTY
Notify theStateObjectrepresenting the scalar expression that follows theTHENidentifier has changed.- See Also:
-
-
Constructor Details
-
WhenClauseStateObject
Creates a newWhenClauseStateObject.- Parameters:
parent- The parent of this state object, which cannot benull- Throws:
NullPointerException- The given parent cannot benull
-
WhenClauseStateObject
public WhenClauseStateObject(CaseExpressionStateObject parent, StateObject whenStateObject, StateObject thenStateObject) Creates a newWhenClauseStateObject.- Parameters:
parent- The parent of this state objectwhenStateObject- TheStateObjectrepresenting the conditional expression that is following theWHENidentifierthenStateObject- TheStateObjectrepresenting the scalar expression that is following theTHENidentifier- Throws:
NullPointerException- The given parent cannot benull
-
WhenClauseStateObject
public WhenClauseStateObject(CaseExpressionStateObject parent, String whenJpqlFragment, String thenJpqlFragment) Creates a newWhenClauseStateObject.- Parameters:
parent- The parent of this state objectwhenJpqlFragment- The string representation of theWHENclause to parse and to convert into aStateObjectthenJpqlFragment- The string representation of theTHENexpression to parse and to convert into aStateObject- Throws:
NullPointerException- The given parent cannot benull
-
-
Method Details
-
accept
Description copied from interface:StateObjectVisits thisStateObjectby the givenvisitor.- Parameters:
visitor- Thevisitorto visit this object
-
addChildren
Description copied from class:AbstractStateObjectAdds the children of thisStateObjectto the given list.- Overrides:
addChildrenin classAbstractConditionalClauseStateObject- Parameters:
children- The list used to store the children
-
addProblems
Description copied from class:AbstractStateObjectAdds to the given list the problems that were found with the current state of thisStateObject, which means there are validation issues.- Overrides:
addProblemsin classAbstractStateObject- Parameters:
problems- The list to which the problems are added
-
getExpression
Description copied from interface:StateObjectReturns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.- Specified by:
getExpressionin interfaceStateObject- Overrides:
getExpressionin classAbstractStateObject- Returns:
- The parsed object when a JPQL query is parsed and converted into a
StateObjectornullwhen the JPQL query is manually created (i.e. not from a string)
-
getIdentifier
Description copied from class:AbstractConditionalClauseStateObjectReturns the JPQL identifier of this clause.- Specified by:
getIdentifierin classAbstractConditionalClauseStateObject- Returns:
- The JPQL identifier of this conditional clause
-
getParent
Description copied from interface:StateObjectReturns the parent of thisStateObject.- Specified by:
getParentin interfaceStateObject- Overrides:
getParentin classAbstractStateObject- Returns:
- Returns the parent of this
StateObject, which isnullonly when this is the root of the hierarchy
-
getThen
Returns theStateObjectrepresenting the scalar expression that is following theTHENidentifier.- Returns:
- Either the
StateObjectrepresenting theTHENexpression ornullif it's not defined
-
hasThen
public boolean hasThen()Determines whether theStateObjectrepresenting the scalar expression is present.- Returns:
truethe scalar expression exists; otherwisefalse
-
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 classAbstractConditionalClauseStateObject- Parameters:
stateObject- TheStateObjectto compare its content to this one- Returns:
trueif both object are equivalent;falseotherwise
-
parseThen
Parses the given JPQL fragment, which will represent theTHENexpression. The JPQL fragment should not start with the identifier.- Parameters:
jpqlFragment- The string representation of theTHENexpression to parse and to convert into aStateObject
-
parseWhen
Parses the given JPQL fragment, which will represent theWHENclause. The JPQL fragment should not start with the identifier.- Parameters:
jpqlFragment- The string representation of theWHENclause to parse and to convert into aStateObject
-
setExpression
Keeps a reference of theparsed objectobject, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects.- Parameters:
expression- Theparsed objectrepresenting aWHENclause
-
setThen
Sets the scalar expression to be the givenStateObject.- Parameters:
thenStateObject- TheStateObjectrepresenting the scalar expression
-
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.- Overrides:
toTextInternalin classAbstractConditionalClauseStateObject- 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
-