All Implemented Interfaces:
ListHolderStateObject<StateObject>, StateObject

public class GroupByClauseStateObject extends AbstractListHolderStateObject<StateObject>
The GROUP BY construct 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
See Also:
  • Field Details

  • Constructor Details

    • GroupByClauseStateObject

      public GroupByClauseStateObject(AbstractSelectStatementStateObject parent)
      Creates a new GroupByClauseStateObject.
      Parameters:
      parent - The parent of this state object, which cannot be null
      Throws:
      NullPointerException - The given parent cannot be null
  • Method Details

    • accept

      public void accept(StateObjectVisitor visitor)
      Description copied from interface: StateObject
      Visits this StateObject by the given visitor.
      Parameters:
      visitor - The visitor to 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 StateObject encapsulating the given path
    • getExpression

      public GroupByClause getExpression()
      Description copied from interface: StateObject
      Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.
      Specified by:
      getExpression in interface StateObject
      Overrides:
      getExpression in class AbstractStateObject
      Returns:
      The parsed object when a JPQL query is parsed and converted into a StateObject or null when the JPQL query is manually created (i.e. not from a string)
    • getParent

      Description copied from interface: StateObject
      Returns the parent of this StateObject.
      Specified by:
      getParent in interface StateObject
      Overrides:
      getParent in class AbstractStateObject
      Returns:
      Returns the parent of this StateObject, which is null only when this is the root of the hierarchy
    • isEquivalent

      public boolean isEquivalent(StateObject stateObject)
      Description copied from interface: StateObject
      Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.
      Specified by:
      isEquivalent in interface StateObject
      Overrides:
      isEquivalent in class AbstractStateObject
      Parameters:
      stateObject - The StateObject to compare its content to this one
      Returns:
      true if both object are equivalent; false otherwise
    • listName

      protected String listName()
      Description copied from class: AbstractListHolderStateObject
      Returns the name that is uniquely identifying the list.
      Specified by:
      listName in class AbstractListHolderStateObject<StateObject>
      Returns:
      The unique name identifying the list
    • parse

      public void parse(String jpqlFragment)
      Parses the given JPQL fragment, which will represent the group by items. The fragment cannot start with the GROUP BY.
      Parameters:
      jpqlFragment - The string representation of the group by items
    • setExpression

      public void setExpression(GroupByClause expression)
      Keeps a reference of the parsed object object, which should only be done when this object is instantiated during the conversion of a parsed JPQL query into StateObjects.
      Parameters:
      expression - The parsed object representing a GROUP BY clause
    • toTextInternal

      protected void toTextInternal(Appendable writer) throws IOException
      Description copied from class: AbstractStateObject
      Prints out a string representation of this StateObject, which should not be used to define a true string representation of a JPQL query but should be used for debugging purposes.
      Specified by:
      toTextInternal in class AbstractStateObject
      Parameters:
      writer - The writer used to print out the string representation
      Throws:
      IOException - This should never happens, it is only required because Appendable is used instead of any concrete class