/**
   * Selects the given cells of the {@code JTable}.
   *
   * @param table the target {@code JTable}.
   * @param cells the cells to select.
   * @throws NullPointerException if {@code cells} is {@code null} or empty.
   * @throws IllegalArgumentException if {@code cells} is {@code null} or empty.
   * @throws IllegalStateException if the {@code JTable} is disabled.
   * @throws IllegalStateException if the {@code JTable} is not showing on the screen.
   * @throws NullPointerException if any element in {@code cells} is {@code null}.
   * @throws IndexOutOfBoundsException if any of the indices of any of the {@code cells} are out of
   *     bounds.
   */
  public void selectCells(final @Nonnull JTable table, final @Nonnull TableCell[] cells) {
    checkNotNullOrEmpty(cells);
    new MultipleSelectionTemplate(robot) {
      @Override
      int elementCount() {
        return cells.length;
      }

      @Override
      void selectElement(int index) {
        selectCell(table, checkNotNull(cells[index]));
      }
    }.multiSelect();
  }
  /**
   * Simulates a user selecting the given rows in the given {@code JTable}.
   *
   * @param table the target {@code JTable}.
   * @param rows the indices of the row to select.
   * @throws NullPointerException if the given array of indices is {@code null}.
   * @throws IllegalArgumentException if the given array of indices is empty.
   * @throws IllegalStateException if the {@code JTable} is disabled.
   * @throws IllegalStateException if the {@code JTable} is not showing on the screen.
   * @throws IndexOutOfBoundsException if any of the given indices is negative, or equal to or
   *     greater than the number of rows in the {@code JTable}.
   */
  @RunsInEDT
  public void selectRows(final @Nonnull JTable table, final @Nonnull int... rows) {
    checkNotNullOrEmpty(rows);
    new MultipleSelectionTemplate(robot) {
      @Override
      int elementCount() {
        return rows.length;
      }

      @Override
      void selectElement(int index) {
        selectCell(table, rows[index], 0);
      }
    }.multiSelect();
  }