public class WhenClauseStateObject extends AbstractConditionalClauseStateObject
WHEN predicate is used to calculate a condition and when it's true, its
THEN will be executed.
when_clause ::= WHEN conditional_expression THEN scalar_expressionor
simple_when_clause ::= WHEN scalar_expression THEN scalar_expressionWhenClause| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
THEN_STATE_OBJECT_PROPERTY
Notify the
StateObject representing the scalar expression that follows the
THEN identifier has changed. |
CONDITIONAL_STATE_OBJECT_PROPERTY| Constructor and Description |
|---|
WhenClauseStateObject(CaseExpressionStateObject parent)
Creates a new
WhenClauseStateObject. |
WhenClauseStateObject(CaseExpressionStateObject parent,
StateObject whenStateObject,
StateObject thenStateObject)
Creates a new
WhenClauseStateObject. |
WhenClauseStateObject(CaseExpressionStateObject parent,
java.lang.String whenJpqlFragment,
java.lang.String thenJpqlFragment)
Creates a new
WhenClauseStateObject. |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(StateObjectVisitor visitor)
Visits this
StateObject by the given visitor. |
protected void |
addChildren(java.util.List<StateObject> children)
Adds the children of this
StateObject to the given list. |
protected void |
addProblems(java.util.List<Problem> problems)
Adds to the given list the problems that were found with the current state of this
StateObject, which means there are validation issues. |
WhenClause |
getExpression()
Returns the actual parsed object if this
StateObject representation of the JPQL query
was created by parsing an existing JPQL query. |
java.lang.String |
getIdentifier()
Returns the JPQL identifier of this clause.
|
CaseExpressionStateObject |
getParent()
Returns the parent of this
StateObject. |
StateObject |
getThen()
Returns the
StateObject representing the scalar expression that is following the
THEN identifier. |
boolean |
hasThen()
Determines whether the
StateObject representing the scalar expression is present. |
boolean |
isEquivalent(StateObject stateObject)
Determines whether the given
StateObject is equivalent to this one, i.e. the
information of both StateObject is the same. |
void |
parseThen(java.lang.String jpqlFragment)
Parses the given JPQL fragment, which will represent the
THEN expression. |
void |
parseWhen(java.lang.String jpqlFragment)
Parses the given JPQL fragment, which will represent the
WHEN clause. |
void |
setExpression(WhenClause expression)
Keeps a reference of the
parsed object object, which should only be
done when this object is instantiated during the conversion of a parsed JPQL query into
StateObjects. |
void |
setThen(StateObject thenStateObject)
Sets the scalar expression to be the given
StateObject. |
void |
toTextInternal(java.lang.Appendable writer)
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. |
andParse, getBuilder, getConditional, hasConditional, orParse, parse, setConditional, shouldEncapsulateORExpressionacceptUnknownVisitor, 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, toTextpublic static final java.lang.String THEN_STATE_OBJECT_PROPERTY
StateObject representing the scalar expression that follows the
THEN identifier has changed.public WhenClauseStateObject(CaseExpressionStateObject parent)
WhenClauseStateObject.parent - The parent of this state object, which cannot be nulljava.lang.NullPointerException - The given parent cannot be nullpublic WhenClauseStateObject(CaseExpressionStateObject parent, StateObject whenStateObject, StateObject thenStateObject)
WhenClauseStateObject.parent - The parent of this state objectwhenStateObject - The StateObject representing the conditional expression that
is following the WHEN identifierthenStateObject - The StateObject representing the scalar expression that
is following the THEN identifierjava.lang.NullPointerException - The given parent cannot be nullpublic WhenClauseStateObject(CaseExpressionStateObject parent, java.lang.String whenJpqlFragment, java.lang.String thenJpqlFragment)
WhenClauseStateObject.parent - The parent of this state objectwhenJpqlFragment - The string representation of the WHEN clause to
parse and to convert into a StateObjectthenJpqlFragment - The string representation of the THEN expression
to parse and to convert into a StateObjectjava.lang.NullPointerException - The given parent cannot be nullpublic void accept(StateObjectVisitor visitor)
StateObject by the given visitor.visitor - The visitor to visit this objectprotected void addChildren(java.util.List<StateObject> children)
StateObject to the given list.addChildren in class AbstractConditionalClauseStateObjectchildren - The list used to store the childrenprotected void addProblems(java.util.List<Problem> problems)
StateObject, which means there are validation issues.addProblems in class AbstractStateObjectproblems - The list to which the problems are addedpublic WhenClause getExpression()
StateObject representation of the JPQL query
was created by parsing an existing JPQL query.getExpression in interface StateObjectgetExpression in class AbstractStateObjectStateObject
or null when the JPQL query is manually created (i.e. not from a string)public java.lang.String getIdentifier()
getIdentifier in class AbstractConditionalClauseStateObjectpublic CaseExpressionStateObject getParent()
StateObject.getParent in interface StateObjectgetParent in class AbstractStateObjectStateObject, which is null only when
this is the root of the hierarchypublic StateObject getThen()
StateObject representing the scalar expression that is following the
THEN identifier.StateObject representing the THEN expression
or null if it's not definedpublic boolean hasThen()
StateObject representing the scalar expression is present.true the scalar expression exists; otherwise falsepublic boolean isEquivalent(StateObject stateObject)
StateObject is equivalent to this one, i.e. the
information of both StateObject is the same.isEquivalent in interface StateObjectisEquivalent in class AbstractConditionalClauseStateObjectstateObject - The StateObject to compare its content to this onetrue if both object are equivalent; false otherwisepublic void parseThen(java.lang.String jpqlFragment)
THEN expression.
The JPQL fragment should not start with the identifier.jpqlFragment - The string representation of the THEN expression
to parse and to convert into a StateObjectpublic void parseWhen(java.lang.String jpqlFragment)
WHEN clause.
The JPQL fragment should not start with the identifier.jpqlFragment - The string representation of the WHEN clause to
parse and to convert into a StateObjectpublic void setExpression(WhenClause expression)
parsed object object, which should only be
done when this object is instantiated during the conversion of a parsed JPQL query into
StateObjects.expression - The parsed object representing a WHEN
clausepublic void setThen(StateObject thenStateObject)
StateObject.thenStateObject - The StateObject representing the scalar expressionpublic void toTextInternal(java.lang.Appendable writer)
throws java.io.IOException
StateObject, which should not be used to
define a true string representation of a JPQL query but should be used for
debugging purposes.toTextInternal in class AbstractConditionalClauseStateObjectwriter - The writer used to print out the string representationjava.io.IOException - This should never happens, it is only required because Appendable
is used instead of any concrete class