Class ConstructorExpressionStateObject
java.lang.Object
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractListHolderStateObject<StateObject>
org.eclipse.persistence.jpa.jpql.tools.model.query.ConstructorExpressionStateObject
- All Implemented Interfaces:
ListHolderStateObject<StateObject>
,StateObject
In the
SELECT
clause a constructor may be used in the SELECT
list to return one or more Java instances. The specified class is not required to be an entity or
to be mapped to the database. The constructor name must be fully qualified.
BNF: constructor_expression ::= NEW constructor_name(constructor_item {, constructor_item}*)
- Since:
- 2.4
- Version:
- 2.4
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Notifies the class name property has changed.static final String
Notify the list ofStateObjects
representing the constructor items. -
Constructor Summary
ConstructorDescriptionCreates a newConstructorExpressionStateObject
.ConstructorExpressionStateObject
(StateObject parent, Class<?> type) Creates a newConstructorExpressionStateObject
.ConstructorExpressionStateObject
(StateObject parent, Class<?> type, String jpqlFragment) Creates a newConstructorExpressionStateObject
.ConstructorExpressionStateObject
(StateObject parent, Class<?> type, List<? extends StateObject> constructorItems) Creates a newConstructorExpressionStateObject
.ConstructorExpressionStateObject
(StateObject parent, String className) Creates a newConstructorExpressionStateObject
.ConstructorExpressionStateObject
(StateObject parent, String className, String jpqlFragment) Creates a newConstructorExpressionStateObject
.ConstructorExpressionStateObject
(StateObject parent, String className, List<? extends StateObject> constructorItems) Creates a newConstructorExpressionStateObject
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(StateObjectVisitor visitor) Visits thisStateObject
by the givenvisitor
.Returns the fully qualified class name that will be used to retrieve the constructor.Returns the actual parsed object if thisStateObject
representation of the JPQL query was created by parsing an existing JPQL query.getType()
Returns the actualIType
that was resolved ornull
if it could not be resolved.boolean
isEquivalent
(StateObject stateObject) Determines whether the givenStateObject
is equivalent to this one, i.e.protected String
listName()
Returns the name that is uniquely identifying the list.void
Parses the given JPQL fragment, which represents the constructor's arguments.protected IType
Resolves the actualIType
based on the class name.void
setClassName
(CharSequence className) Sets the fully qualified class name that will be used to retrieve the constructor.void
setClassName
(Class<?> type) Sets the fully qualified class name that will be used to retrieve the constructor.protected void
setClassNameInternally
(CharSequence className) Sets the fully qualified class name that will be used to retrieve the constructor.void
setExpression
(ConstructorExpression 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
Sets the actualIType
and updates the class name.protected void
toTextInternal
(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.AbstractListHolderStateObject
addChildren, addItem, addItems, addListChangeListener, areChildrenEquivalent, canMoveDown, canMoveUp, getItem, hasItems, initialize, items, itemsSize, moveDown, moveUp, removeItem, removeItems, removeListChangeListener, toStringItems
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
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject
addPropertyChangeListener, children, decorate, findIdentificationVariable, getDeclaration, getDecorator, getGrammar, getManagedTypeProvider, getParent, getQueryBuilder, getRoot, isDecorated, removePropertyChangeListener, setParent, toString, toText
-
Field Details
-
CLASS_NAME_PROPERTY
Notifies the class name property has changed.- See Also:
-
CONSTRUCTOR_ITEMS_LIST
Notify the list ofStateObjects
representing the constructor items.- See Also:
-
-
Constructor Details
-
ConstructorExpressionStateObject
Creates a newConstructorExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
- Throws:
NullPointerException
- The given parent cannot benull
-
ConstructorExpressionStateObject
Creates a newConstructorExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
type
- The fully qualified name of the Java class to instantiate- Throws:
NullPointerException
- The given parent cannot benull
-
ConstructorExpressionStateObject
public ConstructorExpressionStateObject(StateObject parent, Class<?> type, List<? extends StateObject> constructorItems) Creates a newConstructorExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
type
- The Java class to instantiateconstructorItems
- The list of arguments- Throws:
NullPointerException
- The given parent cannot benull
-
ConstructorExpressionStateObject
Creates a newConstructorExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
type
- The Java class to instantiatejpqlFragment
- The portion of the JPQL query that represents the constructor's arguments- Throws:
NullPointerException
- The given parent cannot benull
-
ConstructorExpressionStateObject
Creates a newConstructorExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
className
- The fully qualified name of the Java class to instantiate- Throws:
NullPointerException
- The given parent cannot benull
-
ConstructorExpressionStateObject
public ConstructorExpressionStateObject(StateObject parent, String className, List<? extends StateObject> constructorItems) Creates a newConstructorExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
className
- The fully qualified name of the Java class to instantiateconstructorItems
- The list of arguments- Throws:
NullPointerException
- The given parent cannot benull
-
ConstructorExpressionStateObject
Creates a newConstructorExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
className
- The fully qualified name of the Java class to instantiatejpqlFragment
- The portion of the JPQL query that represents the constructor's arguments- Throws:
NullPointerException
- The given parent cannot benull
-
-
Method Details
-
accept
Description copied from interface:StateObject
Visits thisStateObject
by the givenvisitor
.- Parameters:
visitor
- Thevisitor
to visit this object
-
getClassName
Returns the fully qualified class name that will be used to retrieve the constructor.- Returns:
- The fully qualified class name or an empty string if it is not defined
-
getExpression
Description copied from interface:StateObject
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)
-
getType
Returns the actualIType
that was resolved ornull
if it could not be resolved.- Returns:
- The actual
IType
-
isEquivalent
Description copied from interface: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
-
listName
Description copied from class:AbstractListHolderStateObject
Returns the name that is uniquely identifying the list.- Specified by:
listName
in classAbstractListHolderStateObject<StateObject>
- Returns:
- The unique name identifying the list
-
parse
Parses the given JPQL fragment, which represents the constructor's arguments.- Parameters:
jpqlFragment
- The JPQL fragment, which represents either a single or multiple arguments
-
resolveType
Resolves the actualIType
based on the class name.- Returns:
- The
IType
with the fully qualified class name
-
setClassName
Sets the fully qualified class name that will be used to retrieve the constructor.- Parameters:
className
- The fully qualified class name
-
setClassName
Sets the fully qualified class name that will be used to retrieve the constructor.- Parameters:
type
- The type used to retrieve its fully qualified class name
-
setClassNameInternally
Sets the fully qualified class name that will be used to retrieve the constructor.- Parameters:
className
- The fully qualified class name
-
setExpression
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 aNEW
expression
-
setType
Sets the actualIType
and updates the class name.- Parameters:
type
- The newIType
-
toTextInternal
Description copied from class:AbstractStateObject
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:
IOException
- This should never happens, it is only required becauseAppendable
is used instead of any concrete class
-