@Override
            public V next() {
                if (!iter.hasNext()) {
                    if (group != null) {
                        Group current = group;
                        group = null;
                        return transform(current);
                    } else {
                        throw new NoSuchElementException();
                    }
                }

                while (iter.hasNext()) {
                    @SuppressWarnings("unchecked") //This type is mandated by the key type
                    K[] row = (K[]) iter.next().toArray();
                    if (group == null) {
                        group = new GroupImpl(groupExpressions, maps);
                        groupId = row[0];
                        group.add(row);
                    } else if (Objects.equals(groupId, row[0])) {
                        group.add(row);
                    } else {
                        Group current = group;
                        group = new GroupImpl(groupExpressions, maps);
                        groupId = row[0];
                        group.add(row);
                        return transform(current);
                    }
                }
                Group current = group;
                group = null;
                return transform(current);
            }
Provides aggregated results as an iterator

@author tiwe

@param <K>
@param <V>
querydsl-core/src/main/java/com/querydsl/core/group/GroupByIterate.java