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
AWHEN
predicate is used to calculate a condition and when it's true, itsTHEN
will be executed.BNF:orwhen_clause ::= WHEN conditional_expression THEN scalar_expression
BNF:simple_when_clause ::= WHEN scalar_expression THEN scalar_expression
- Since:
- 2.4
- Version:
- 2.4
- Author:
- Pascal Filion
- See Also:
WhenClause
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
THEN_STATE_OBJECT_PROPERTY
Notify theStateObject
representing the scalar expression that follows theTHEN
identifier 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 void
accept(StateObjectVisitor visitor)
Visits thisStateObject
by the givenvisitor
.WhenClause
getExpression()
Returns the actual parsed object if thisStateObject
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 thisStateObject
.StateObject
getThen()
Returns theStateObject
representing the scalar expression that is following theTHEN
identifier.boolean
hasThen()
Determines whether theStateObject
representing the scalar expression is present.boolean
isEquivalent(StateObject stateObject)
Determines whether the givenStateObject
is equivalent to this one, i.e.void
parseThen(java.lang.String jpqlFragment)
Parses the given JPQL fragment, which will represent theTHEN
expression.void
parseWhen(java.lang.String jpqlFragment)
Parses the given JPQL fragment, which will represent theWHEN
clause.void
setExpression(WhenClause expression)
Keeps a reference of theparsed object
object, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects
.void
setThen(StateObject thenStateObject)
Sets the scalar expression to be the givenStateObject
.void
toTextInternal(java.lang.Appendable writer)
-
Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractConditionalClauseStateObject
andParse, getBuilder, getConditional, hasConditional, orParse, parse, setConditional
-
Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
addPropertyChangeListener, children, decorate, equals, findIdentificationVariable, getDeclaration, getDecorator, getGrammar, getManagedTypeProvider, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, isDecorated, removePropertyChangeListener, setExpression, setParent, toString, toString, toText
-
-
-
-
Field Detail
-
THEN_STATE_OBJECT_PROPERTY
public static final java.lang.String THEN_STATE_OBJECT_PROPERTY
Notify theStateObject
representing the scalar expression that follows theTHEN
identifier 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
- TheStateObject
representing the conditional expression that is following theWHEN
identifierthenStateObject
- TheStateObject
representing the scalar expression that is following theTHEN
identifier- 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 theWHEN
clause to parse and to convert into aStateObject
thenJpqlFragment
- The string representation of theTHEN
expression 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 thisStateObject
by the givenvisitor
.- Parameters:
visitor
- Thevisitor
to visit this object
-
getExpression
public WhenClause getExpression()
Returns the actual parsed object if thisStateObject
representation of the JPQL query was created by parsing an existing JPQL query.- Specified by:
getExpression
in interfaceStateObject
- Overrides:
getExpression
in classAbstractStateObject
- Returns:
- The parsed object when a JPQL query is parsed and converted into a
StateObject
ornull
when 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:
getIdentifier
in classAbstractConditionalClauseStateObject
- Returns:
- The JPQL identifier of this conditional clause
-
getParent
public CaseExpressionStateObject getParent()
Returns the parent of thisStateObject
.- Specified by:
getParent
in interfaceStateObject
- Overrides:
getParent
in classAbstractStateObject
- Returns:
- Returns the parent of this
StateObject
, which isnull
only when this is the root of the hierarchy
-
getThen
public StateObject getThen()
Returns theStateObject
representing the scalar expression that is following theTHEN
identifier.- Returns:
- Either the
StateObject
representing theTHEN
expression ornull
if it's not defined
-
hasThen
public boolean hasThen()
Determines whether theStateObject
representing the scalar expression is present.- Returns:
true
the scalar expression exists; otherwisefalse
-
isEquivalent
public boolean isEquivalent(StateObject stateObject)
Determines whether the givenStateObject
is equivalent to this one, i.e. the information of bothStateObject
is the same.- Specified by:
isEquivalent
in interfaceStateObject
- Overrides:
isEquivalent
in classAbstractConditionalClauseStateObject
- Parameters:
stateObject
- TheStateObject
to compare its content to this one- Returns:
true
if both object are equivalent;false
otherwise
-
parseThen
public void parseThen(java.lang.String jpqlFragment)
Parses the given JPQL fragment, which will represent theTHEN
expression. The JPQL fragment should not start with the identifier.- Parameters:
jpqlFragment
- The string representation of theTHEN
expression to parse and to convert into aStateObject
-
parseWhen
public void parseWhen(java.lang.String jpqlFragment)
Parses the given JPQL fragment, which will represent theWHEN
clause. The JPQL fragment should not start with the identifier.- Parameters:
jpqlFragment
- The string representation of theWHEN
clause to parse and to convert into aStateObject
-
setExpression
public void setExpression(WhenClause expression)
Keeps a reference of theparsed object
object, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects
.- Parameters:
expression
- Theparsed object
representing aWHEN
clause
-
setThen
public void setThen(StateObject thenStateObject)
Sets the scalar expression to be the givenStateObject
.- Parameters:
thenStateObject
- TheStateObject
representing the scalar expression
-
toTextInternal
public void toTextInternal(java.lang.Appendable writer) throws java.io.IOException
- Throws:
java.io.IOException
-
-