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
public class WhenClauseStateObject extends AbstractConditionalClauseStateObject
AWHENpredicate is used to calculate a condition and when it's true, itsTHENwill be executed.BNF:orwhen_clause ::= WHEN conditional_expression THEN scalar_expressionBNF:simple_when_clause ::= WHEN scalar_expression THEN scalar_expression- Version:
- 2.4
- See Also:
WhenClause- Author:
- Pascal Filion
- Since:
- 2.4
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringTHEN_STATE_OBJECT_PROPERTYNotify 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
Constructors Constructor Description WhenClauseStateObject(CaseExpressionStateObject parent)Creates a newWhenClauseStateObject.WhenClauseStateObject(CaseExpressionStateObject parent, java.lang.String whenJpqlFragment, java.lang.String thenJpqlFragment)Creates a newWhenClauseStateObject.WhenClauseStateObject(CaseExpressionStateObject parent, StateObject whenStateObject, StateObject thenStateObject)Creates a newWhenClauseStateObject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(StateObjectVisitor visitor)Visits thisStateObjectby the givenvisitor.protected voidaddChildren(java.util.List<StateObject> children)Adds the children of thisStateObjectto the given list.protected voidaddProblems(java.util.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.WhenClausegetExpression()Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.java.lang.StringgetIdentifier()Returns the JPQL identifier of this clause.CaseExpressionStateObjectgetParent()Returns the parent of thisStateObject.StateObjectgetThen()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. the information of bothStateObjectis the same.voidparseThen(java.lang.String jpqlFragment)Parses the given JPQL fragment, which will represent theTHENexpression.voidparseWhen(java.lang.String jpqlFragment)Parses 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(java.lang.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, shouldEncapsulateORExpression
-
Methods 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 Detail
-
THEN_STATE_OBJECT_PROPERTY
public static final java.lang.String THEN_STATE_OBJECT_PROPERTY
Notify theStateObjectrepresenting the scalar expression that follows theTHENidentifier has changed.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
WhenClauseStateObject
public WhenClauseStateObject(CaseExpressionStateObject parent)
Creates a newWhenClauseStateObject.- Parameters:
parent- The parent of this state object, which cannot benull- Throws:
java.lang.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:
java.lang.NullPointerException- The given parent cannot benull
-
WhenClauseStateObject
public WhenClauseStateObject(CaseExpressionStateObject parent, java.lang.String whenJpqlFragment, java.lang.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:
java.lang.NullPointerException- The given parent cannot benull
-
-
Method Detail
-
accept
public void accept(StateObjectVisitor visitor)
Visits thisStateObjectby the givenvisitor.- Parameters:
visitor- Thevisitorto visit this object
-
addChildren
protected void addChildren(java.util.List<StateObject> children)
Adds the children of thisStateObjectto the given list.- Overrides:
addChildrenin classAbstractConditionalClauseStateObject- Parameters:
children- The list used to store the children
-
addProblems
protected void addProblems(java.util.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.- Overrides:
addProblemsin classAbstractStateObject- Parameters:
problems- The list to which the problems are added
-
getExpression
public WhenClause getExpression()
Returns 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
public java.lang.String getIdentifier()
Returns the JPQL identifier of this clause.- Specified by:
getIdentifierin classAbstractConditionalClauseStateObject- Returns:
- The JPQL identifier of this conditional clause
-
getParent
public CaseExpressionStateObject getParent()
Returns 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
public StateObject 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
public boolean isEquivalent(StateObject stateObject)
Determines 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
public void parseThen(java.lang.String jpqlFragment)
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
public void parseWhen(java.lang.String jpqlFragment)
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
public void setExpression(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.- Parameters:
expression- Theparsed objectrepresenting aWHENclause
-
setThen
public void setThen(StateObject thenStateObject)
Sets the scalar expression to be the givenStateObject.- Parameters:
thenStateObject- TheStateObjectrepresenting the scalar expression
-
toTextInternal
public void toTextInternal(java.lang.Appendable writer) throws java.io.IOExceptionPrints 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:
java.io.IOException- This should never happens, it is only required becauseAppendableis used instead of any concrete class
-
-