Class GroupByClause

  • All Implemented Interfaces:
    Expression

    public final class GroupByClause
    extends AbstractExpression
    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}*

    Version:
    2.5.1
    Author:
    Pascal Filion
    Since:
    2.3
    • Constructor Detail

      • GroupByClause

        public GroupByClause​(AbstractExpression parent)
        Creates a new GroupByClause.
        Parameters:
        parent - The parent of this expression
    • Method Detail

      • buildCollectionExpression

        public CollectionExpression buildCollectionExpression()
        Creates a new CollectionExpression that will wrap the single group by item.
        Returns:
        The single group by item represented by a temporary collection
      • getActualIdentifier

        public java.lang.String getActualIdentifier()
        Returns the actual GROUP BY found in the string representation of the JPQL query, which has the actual case that was used.
        Returns:
        The GROUP BY identifier that was actually parsed
      • getGroupByItems

        public Expression getGroupByItems()
        Returns the Expression that represents the list of group by items if any was parsed.
        Returns:
        The expression that was parsed representing the list of items
      • hasGroupByItems

        public boolean hasGroupByItems()
        Determines whether the list of items was parsed.
        Returns:
        true if at least one item was parsed; false otherwise
      • hasSpaceAfterGroupBy

        public boolean hasSpaceAfterGroupBy()
        Determines whether a whitespace was found after GROUP BY.
        Returns:
        true if there was a whitespace after GROUP BY; false otherwise
      • parse

        protected void parse​(WordParser wordParser,
                             boolean tolerant)
        Parses the query by starting at the current position, which is part of the given WordParser.
        Specified by:
        parse in class AbstractExpression
        Parameters:
        wordParser - The text to parse based on the current position of the cursor
        tolerant - Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries
      • toParsedText

        protected void toParsedText​(java.lang.StringBuilder writer,
                                    boolean actual)
        Generates a string representation of this Expression, including its children, if it has any.
        Specified by:
        toParsedText in class AbstractExpression
        Parameters:
        writer - The buffer used to append this Expression's string representation
        actual - Determines whether the string representation should represent what was parsed, i.e. include any "virtual" whitespace (such as ending whitespace) and the actual case of the JPQL identifiers