Class TreatExpressionStateObject
- java.lang.Object
-
- org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
-
- org.eclipse.persistence.jpa.jpql.tools.model.query.TreatExpressionStateObject
-
- All Implemented Interfaces:
StateObject
public class TreatExpressionStateObject extends AbstractStateObject
Returns an expression that allows to treat its base as if it were a subclass of the class returned by the base.Note:
EclipseLinkStateObjectVisitor
needs to be used to traverse this state object.BNF:join_treat ::= TREAT(collection_valued_path_expression [AS] entity_type_literal)
- Version:
- 2.4
- See Also:
TreatExpression
- Author:
- Pascal Filion
- Since:
- 2.4
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
AS_PROPERTY
Notifies the visibility of theAS
identifier has changed.static java.lang.String
ENTITY_TYPE_NAME_PROPERTY
Notifies the entity type name property has changed.
-
Constructor Summary
Constructors Constructor Description TreatExpressionStateObject(JoinStateObject parent)
Creates a newTreatExpressionStateObject
.TreatExpressionStateObject(JoinStateObject parent, boolean as, java.lang.String entityTypeName)
Creates a newTreatExpressionStateObject
.TreatExpressionStateObject(JoinStateObject parent, java.lang.String entityTypeName)
Creates a newTreatExpressionStateObject
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(StateObjectVisitor visitor)
Visits thisStateObject
by the givenvisitor
.TreatExpressionStateObject
addAs()
Makes sure theAS
identifier is specified.protected void
addChildren(java.util.List<StateObject> children)
Adds the children of thisStateObject
to the given list.void
appendToEntityTypeName(java.lang.String text)
Appends the given text to the existing entity type name property.IEntity
getEntity()
Resolves the entity type name to the external form of the actualIEntity
.java.lang.String
getEntityTypeName()
Returns the name of the entity that is used to downcast the join association path.TreatExpression
getExpression()
Returns the actual parsed object if thisStateObject
representation of the JPQL query was created by parsing an existing JPQL query.JoinStateObject
getJoin()
Returns the reference of theJoinStateObject
.StateObject
getJoinAssociationIdentificationVariable()
Returns theStateObject
representing the identification variable that starts the path expression, which can be a sample identification variable, a map value, map key or map entry expression.CollectionValuedPathExpressionStateObject
getJoinAssociationPathStateObject()
Returns theCollectionValuedPathExpressionStateObject
representing the join association path.boolean
hasAs()
Determines whether theAS
identifier is used.boolean
hasEntityTypeName()
Determines whether the.protected void
initialize()
Initializes this state object.boolean
isEquivalent(StateObject stateObject)
Determines whether the givenStateObject
is equivalent to this one, i.e. the information of bothStateObject
is the same.void
removeAs()
Makes sure theAS
identifier is not specified.void
setAs(boolean as)
Sets whether theAS
identifier should be used.void
setEntityTypeName(java.lang.Class<?> entityType)
Sets the name of the entity that is used to downcast the join association path.void
setEntityTypeName(java.lang.String entityTypeName)
Sets the name of the entity that is used to downcast the join association path.void
setEntityTypeName(IEntity entityType)
Sets the name of the entity that is used to downcast the join association path.void
setExpression(TreatExpression 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
toggleAs()
Toggles the visibility of theAS
identifier; either adds it if it's not present otherwise removes it if it's present.protected void
toTextInternal(java.lang.Appendable writer)
Prints out a string representation of thisStateObject
, which should not be used to define atrue
string 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, getGrammar, getManagedTypeProvider, getParent, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, isDecorated, parent, parent, parent, removePropertyChangeListener, setExpression, setParent, toString, toString, toStringInternal, toStringItems, toText
-
-
-
-
Field Detail
-
AS_PROPERTY
public static final java.lang.String AS_PROPERTY
Notifies the visibility of theAS
identifier has changed.- See Also:
- Constant Field Values
-
ENTITY_TYPE_NAME_PROPERTY
public static final java.lang.String ENTITY_TYPE_NAME_PROPERTY
Notifies the entity type name property has changed.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TreatExpressionStateObject
public TreatExpressionStateObject(JoinStateObject parent)
Creates a newTreatExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which is temporary since this state object will be parented with the state object representing the join's association path expression
-
TreatExpressionStateObject
public TreatExpressionStateObject(JoinStateObject parent, boolean as, java.lang.String entityTypeName)
Creates a newTreatExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which is temporary since this state object will be parented with the state object representing the join's association path expressionas
- Determines whether theAS
identifier is used or notentityTypeName
- The entity type name used to cast the base expression
-
TreatExpressionStateObject
public TreatExpressionStateObject(JoinStateObject parent, java.lang.String entityTypeName)
Creates a newTreatExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which is temporary since this state object will be parented with the state object representing the join's association path expressionentityTypeName
- The entity type name used to cast the base expression
-
-
Method Detail
-
accept
public void accept(StateObjectVisitor visitor)
Visits thisStateObject
by the givenvisitor
.- Parameters:
visitor
- Thevisitor
to visit this object
-
addAs
public TreatExpressionStateObject addAs()
Makes sure theAS
identifier is specified.- Returns:
- This object
-
addChildren
protected void addChildren(java.util.List<StateObject> children)
Adds the children of thisStateObject
to the given list.- Overrides:
addChildren
in classAbstractStateObject
- Parameters:
children
- The list used to store the children
-
appendToEntityTypeName
public void appendToEntityTypeName(java.lang.String text)
Appends the given text to the existing entity type name property.- Parameters:
text
- The text to append to the entity type name property or nothing is done if the given value isnull
-
getEntity
public IEntity getEntity()
Resolves the entity type name to the external form of the actualIEntity
.- Returns:
- Either the
IEntity
with the same entity type name ornull
if the managed type provider does not have an entity with that name
-
getEntityTypeName
public java.lang.String getEntityTypeName()
Returns the name of the entity that is used to downcast the join association path.- Returns:
- The name of the entity used for down casting
-
getExpression
public TreatExpression 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)
-
getJoin
public JoinStateObject getJoin()
Returns the reference of theJoinStateObject
.- Returns:
- The "owning" of this object
-
getJoinAssociationIdentificationVariable
public StateObject getJoinAssociationIdentificationVariable()
Returns theStateObject
representing the identification variable that starts the path expression, which can be a sample identification variable, a map value, map key or map entry expression.- Returns:
- The root of the path expression
-
getJoinAssociationPathStateObject
public CollectionValuedPathExpressionStateObject getJoinAssociationPathStateObject()
Returns theCollectionValuedPathExpressionStateObject
representing the join association path.- Returns:
- The state object representing the join association path
-
hasAs
public boolean hasAs()
Determines whether theAS
identifier is used.- Returns:
true
if theAS
identifier is used;false
otherwise
-
hasEntityTypeName
public boolean hasEntityTypeName()
Determines whether the.- Returns:
true
if the entity type name has been defined;false
otherwise
-
initialize
protected void initialize()
Initializes this state object.- Overrides:
initialize
in classAbstractStateObject
-
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 classAbstractStateObject
- Parameters:
stateObject
- TheStateObject
to compare its content to this one- Returns:
true
if both object are equivalent;false
otherwise
-
removeAs
public void removeAs()
Makes sure theAS
identifier is not specified.
-
setAs
public void setAs(boolean as)
Sets whether theAS
identifier should be used.- Parameters:
as
-true
if theAS
identifier should be used part;false
otherwise
-
setEntityTypeName
public void setEntityTypeName(java.lang.Class<?> entityType)
Sets the name of the entity that is used to downcast the join association path.- Parameters:
entityType
- The Java class representing the entity type
-
setEntityTypeName
public void setEntityTypeName(IEntity entityType)
Sets the name of the entity that is used to downcast the join association path.- Parameters:
entityType
- The external form of the entity type
-
setEntityTypeName
public void setEntityTypeName(java.lang.String entityTypeName)
Sets the name of the entity that is used to downcast the join association path.- Parameters:
entityTypeName
- The new name of the entity used for down casting
-
setExpression
public void setExpression(TreatExpression 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 theTREAD
expression
-
toggleAs
public void toggleAs()
Toggles the visibility of theAS
identifier; either adds it if it's not present otherwise removes it if it's present.
-
toTextInternal
protected void toTextInternal(java.lang.Appendable writer) throws java.io.IOException
Prints out a string representation of thisStateObject
, which should not be used to define atrue
string representation of a JPQL query but should be used for debugging purposes.- Specified by:
toTextInternal
in classAbstractStateObject
- Parameters:
writer
- The writer used to print out the string representation- Throws:
java.io.IOException
- This should never happens, it is only required becauseAppendable
is used instead of any concrete class
-
-