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
public class ConstructorExpressionStateObject extends AbstractListHolderStateObject<StateObject>
In theSELECTclause a constructor may be used in theSELECTlist 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
- Author:
- Pascal Filion
- See Also:
ConstructorExpression
-
-
Field Summary
Fields Modifier and Type Field Description static StringCLASS_NAME_PROPERTYNotifies the class name property has changed.static StringCONSTRUCTOR_ITEMS_LISTNotify the list ofStateObjectsrepresenting the constructor items.
-
Constructor Summary
Constructors Constructor Description ConstructorExpressionStateObject(StateObject parent)Creates 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(StateObjectVisitor visitor)Visits thisStateObjectby the givenvisitor.StringgetClassName()Returns the fully qualified class name that will be used to retrieve the constructor.ConstructorExpressiongetExpression()Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.ITypegetType()Returns the actualITypethat was resolved ornullif it could not be resolved.booleanisEquivalent(StateObject stateObject)Determines whether the givenStateObjectis equivalent to this one, i.e.voidparse(String jpqlFragment)Parses the given JPQL fragment, which represents the constructor's arguments.voidsetClassName(CharSequence className)Sets the fully qualified class name that will be used to retrieve the constructor.voidsetClassName(Class<?> type)Sets the fully qualified class name that will be used to retrieve the constructor.voidsetExpression(ConstructorExpression 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.voidsetType(IType type)Sets the actualITypeand updates the class name.-
Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractListHolderStateObject
addItem, addItems, addListChangeListener, canMoveDown, canMoveUp, getItem, hasItems, items, itemsSize, moveDown, moveUp, removeItem, removeItems, removeListChangeListener
-
Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
addPropertyChangeListener, children, decorate, equals, findIdentificationVariable, getDeclaration, getDecorator, getGrammar, getManagedTypeProvider, getParent, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, isDecorated, removePropertyChangeListener, setExpression, setParent, toString, toString, toText
-
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 Detail
-
CLASS_NAME_PROPERTY
public static final String CLASS_NAME_PROPERTY
Notifies the class name property has changed.- See Also:
- Constant Field Values
-
CONSTRUCTOR_ITEMS_LIST
public static final String CONSTRUCTOR_ITEMS_LIST
Notify the list ofStateObjectsrepresenting the constructor items.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ConstructorExpressionStateObject
public ConstructorExpressionStateObject(StateObject parent)
Creates a newConstructorExpressionStateObject.- Parameters:
parent- The parent of this state object, which cannot benull- Throws:
NullPointerException- The given parent cannot benull
-
ConstructorExpressionStateObject
public ConstructorExpressionStateObject(StateObject parent, Class<?> type)
Creates a newConstructorExpressionStateObject.- Parameters:
parent- The parent of this state object, which cannot benulltype- 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 benulltype- The Java class to instantiateconstructorItems- The list of arguments- Throws:
NullPointerException- The given parent cannot benull
-
ConstructorExpressionStateObject
public ConstructorExpressionStateObject(StateObject parent, Class<?> type, String jpqlFragment)
Creates a newConstructorExpressionStateObject.- Parameters:
parent- The parent of this state object, which cannot benulltype- 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
public ConstructorExpressionStateObject(StateObject parent, String className)
Creates a newConstructorExpressionStateObject.- Parameters:
parent- The parent of this state object, which cannot benullclassName- 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 benullclassName- The fully qualified name of the Java class to instantiateconstructorItems- The list of arguments- Throws:
NullPointerException- The given parent cannot benull
-
ConstructorExpressionStateObject
public ConstructorExpressionStateObject(StateObject parent, String className, String jpqlFragment)
Creates a newConstructorExpressionStateObject.- Parameters:
parent- The parent of this state object, which cannot benullclassName- 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 Detail
-
accept
public void accept(StateObjectVisitor visitor)
Visits thisStateObjectby the givenvisitor.- Parameters:
visitor- Thevisitorto visit this object
-
getClassName
public String 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
public ConstructorExpression 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)
-
getType
public IType getType()
Returns the actualITypethat was resolved ornullif it could not be resolved.- Returns:
- The actual
IType
-
isEquivalent
public boolean isEquivalent(StateObject stateObject)
Description copied from class:AbstractStateObjectDetermines 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
-
parse
public void parse(String jpqlFragment)
Parses the given JPQL fragment, which represents the constructor's arguments.- Parameters:
jpqlFragment- The JPQL fragment, which represents either a single or multiple arguments
-
setClassName
public void setClassName(CharSequence className)
Sets the fully qualified class name that will be used to retrieve the constructor.- Parameters:
className- The fully qualified class name
-
setClassName
public void setClassName(Class<?> type)
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
-
setExpression
public void setExpression(ConstructorExpression 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 aNEWexpression
-
-