Class GroupByClauseStateObject
- 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.GroupByClauseStateObject
-
- All Implemented Interfaces:
ListHolderStateObject<StateObject>,StateObject
public class GroupByClauseStateObject extends AbstractListHolderStateObject<StateObject>
TheGROUP BYconstruct enables the aggregation of values according to the properties of an entity class.BNF:groupby_clause ::= GROUP BY groupby_item {, groupby_item}*- Since:
- 2.4
- Version:
- 2.4
- Author:
- Pascal Filion
- See Also:
GroupByClause
-
-
Field Summary
Fields Modifier and Type Field Description static StringGROUP_BY_ITEMS_LISTNotify the list ofStateObjectsrepresenting theGROUP BYitems.
-
Constructor Summary
Constructors Constructor Description GroupByClauseStateObject(AbstractSelectStatementStateObject parent)Creates a newGroupByClauseStateObject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(StateObjectVisitor visitor)Visits thisStateObjectby the givenvisitor.StateObjectaddGroupByItem(String path)Adds the given path as a select item, which can either be an identification variable or a state-field path expression.GroupByClausegetExpression()Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.AbstractSelectStatementStateObjectgetParent()Returns the parent of thisStateObject.booleanisEquivalent(StateObject stateObject)Determines whether the givenStateObjectis equivalent to this one, i.e.voidparse(String jpqlFragment)Parses the given JPQL fragment, which will represent the group by items.voidsetExpression(GroupByClause 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.-
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, 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, getQueryBuilder, getRoot, isDecorated, removePropertyChangeListener, setParent, toString, toText
-
-
-
-
Field Detail
-
GROUP_BY_ITEMS_LIST
public static final String GROUP_BY_ITEMS_LIST
Notify the list ofStateObjectsrepresenting theGROUP BYitems.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GroupByClauseStateObject
public GroupByClauseStateObject(AbstractSelectStatementStateObject parent)
Creates a newGroupByClauseStateObject.- Parameters:
parent- The parent of this state object, which cannot benull- 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
-
addGroupByItem
public StateObject addGroupByItem(String path)
Adds the given path as a select item, which can either be an identification variable or a state-field path expression.- Parameters:
path- Either an identification variable or a state-field path expression- Returns:
- The
StateObjectencapsulating the given path
-
getExpression
public GroupByClause 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)
-
getParent
public AbstractSelectStatementStateObject getParent()
Returns the parent of thisStateObject.- Specified by:
getParentin interfaceStateObject- Overrides:
getParentin classAbstractStateObject- Returns:
- Returns the parent of this
StateObject, which isnullonly when this is the root of the hierarchy
-
isEquivalent
public boolean isEquivalent(StateObject stateObject)
Determines 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 will represent the group by items. The fragment cannot start with theGROUP BY.- Parameters:
jpqlFragment- The string representation of the group by items
-
setExpression
public void setExpression(GroupByClause 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 aGROUP BYclause
-
-