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
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)
- Since:
- 2.4
- Version:
- 2.4
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newTreatExpressionStateObject.TreatExpressionStateObject(JoinStateObject parent, boolean as, String entityTypeName) Creates a newTreatExpressionStateObject.TreatExpressionStateObject(JoinStateObject parent, String entityTypeName) Creates a newTreatExpressionStateObject. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(StateObjectVisitor visitor) Visits thisStateObjectby the givenvisitor.addAs()Makes sure theASidentifier is specified.protected voidaddChildren(List<StateObject> children) Adds the children of thisStateObjectto the given list.voidappendToEntityTypeName(String text) Appends the given text to the existing entity type name property.Resolves the entity type name to the external form of the actualIEntity.Returns the name of the entity that is used to downcast the join association path.Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.getJoin()Returns the reference of theJoinStateObject.Returns theStateObjectrepresenting 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 theCollectionValuedPathExpressionStateObjectrepresenting the join association path.booleanhasAs()Determines whether theASidentifier is used.booleanDetermines whether the.protected voidInitializes this state object.booleanisEquivalent(StateObject stateObject) Determines whether the givenStateObjectis equivalent to this one, i.e.voidremoveAs()Makes sure theASidentifier is not specified.voidsetAs(boolean as) Sets whether theASidentifier should be used.voidsetEntityTypeName(Class<?> entityType) Sets the name of the entity that is used to downcast the join association path.voidsetEntityTypeName(String entityTypeName) Sets the name of the entity that is used to downcast the join association path.voidsetEntityTypeName(IEntity entityType) Sets the name of the entity that is used to downcast the join association path.voidsetExpression(TreatExpression 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.voidtoggleAs()Toggles the visibility of theASidentifier; either adds it if it's not present otherwise removes it if it's present.protected 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.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 Details
-
AS_PROPERTY
Notifies the visibility of theASidentifier has changed.- See Also:
-
ENTITY_TYPE_NAME_PROPERTY
Notifies the entity type name property has changed.- See Also:
-
-
Constructor Details
-
TreatExpressionStateObject
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
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 theASidentifier is used or notentityTypeName- The entity type name used to cast the base expression
-
TreatExpressionStateObject
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 Details
-
accept
Description copied from interface:StateObjectVisits thisStateObjectby the givenvisitor.- Parameters:
visitor- Thevisitorto visit this object
-
addAs
Makes sure theASidentifier is specified.- Returns:
- This object
-
addChildren
Description copied from class:AbstractStateObjectAdds the children of thisStateObjectto the given list.- Overrides:
addChildrenin classAbstractStateObject- Parameters:
children- The list used to store the children
-
appendToEntityTypeName
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
Resolves the entity type name to the external form of the actualIEntity.- Returns:
- Either the
IEntitywith the same entity type name ornullif the managed type provider does not have an entity with that name
-
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
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)
-
getJoin
Returns the reference of theJoinStateObject.- Returns:
- The "owning" of this object
-
getJoinAssociationIdentificationVariable
Returns theStateObjectrepresenting 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
Returns theCollectionValuedPathExpressionStateObjectrepresenting the join association path.- Returns:
- The state object representing the join association path
-
hasAs
public boolean hasAs()Determines whether theASidentifier is used.- Returns:
trueif theASidentifier is used;falseotherwise
-
hasEntityTypeName
public boolean hasEntityTypeName()Determines whether the.- Returns:
trueif the entity type name has been defined;falseotherwise
-
initialize
protected void initialize()Description copied from class:AbstractStateObjectInitializes this state object.- Overrides:
initializein classAbstractStateObject
-
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 classAbstractStateObject- Parameters:
stateObject- TheStateObjectto compare its content to this one- Returns:
trueif both object are equivalent;falseotherwise
-
removeAs
public void removeAs()Makes sure theASidentifier is not specified. -
setAs
public void setAs(boolean as) Sets whether theASidentifier should be used.- Parameters:
as-trueif theASidentifier should be used part;falseotherwise
-
setEntityTypeName
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
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
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
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 theTREADexpression
-
toggleAs
public void toggleAs()Toggles the visibility of theASidentifier; either adds it if it's not present otherwise removes it if it's present. -
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.- Specified by:
toTextInternalin classAbstractStateObject- 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
-