/**
   * Add the table returning its index or -1 if rejected
   *
   * @param table
   * @param logger
   * @return
   */
  public int addTable(T table) {
    if (TableUtils.findTableIndex(this, table.getName(), true) != -1) {
      throw new RuntimeException("Table already exists: " + table.getName());
    }

    if (table.getImmutableId() == -1) {
      throw new RuntimeException("Invalid table immutable id in table: " + table.getName());
    }

    // we throw an exception if the id is already used because this will
    // be caused by a code error rather than a user error
    if (tablesById.get(table.getImmutableId()) != null) {
      throw new RuntimeException("Duplicate table id");
    }

    tablesByIndx.add(table);
    tablesById.put(table.getImmutableId(), table);
    return tablesByIndx.size() - 1;
  }