code: public void addGroupedRow(int rowIndex) {
          int[][] newRowGroups = getRowGroups();
          // Create a group if none exists.
          if (newRowGroups.length == 0) {
              newRowGroups = new int[][]{{rowIndex}};
          } else {
              int lastGroupIndex = newRowGroups.length - 1;
              int[] lastGroup = newRowGroups[lastGroupIndex];
              int groupSize = lastGroup.length;
              int[] newLastGroup = new int[groupSize + 1];
              System.arraycopy(lastGroup, 0, newLastGroup, 0, groupSize);
              newLastGroup[groupSize] = rowIndex;
              newRowGroups[lastGroupIndex] = newLastGroup;
          }
          setRowGroups(newRowGroups);
      }
docs: Adds the specified row index to the last row group. In case there are no groups, a new group
  will be created.
  
  @param rowIndex the index of the row that should be grouped