@Test(expected = IllegalStateException.class) public void testThatRenamingTableThrowsExceptionWhenNameIsAlreadyTaken() { Table usersTable = new Table("users") .addColumn(new Column("id", bigint(), IDENTITY, AUTO_INCREMENT)); Table playersTable = new Table("players") .addColumn(new Column("id", bigint(), IDENTITY, AUTO_INCREMENT)); new Catalog("test-db") .addTable(usersTable) .addTable(playersTable); usersTable.rename("players"); }
public Catalog addTable(Table table) { checkArgument(table != null, "You must specify a 'table'."); checkArgument(!containsTable(table.getName()), "Catalog: '" + name + "' already contains a table: '" + table.getName() + "'."); checkArgument(!containsView(table.getName()), "Catalog: '" + name + "' already contains a view: '" + table.getName() + "'."); checkArgument(!table.getColumns().isEmpty(), "Table: '" + table.getName() + "' doesn't contain any columns."); checkArgument(!table.getIdentityColumns().isEmpty(), "Table: '" + table.getName() + "' has no identity columns."); tables.add(table); table.setParent(this); return this; }
Catalog implements Copyable<Catalog> { public Catalog addTable(Table table) { checkArgument(table != null, "You must specify a 'table'."); checkArgument(!containsTable(table.getName()), "Catalog: '" + name + "' already contains a table: '" + table.getName() + "'."); checkArgument(!containsView(table.getName()), "Catalog: '" + name + "' already contains a view: '" + table.getName() + "'."); checkArgument(!table.getColumns().isEmpty(), "Table: '" + table.getName() + "' doesn't contain any columns."); checkArgument(!table.getIdentityColumns().isEmpty(), "Table: '" + table.getName() + "' has no identity columns."); tables.add(table); table.setParent(this); return this; } }
Catalog implements Copyable<Catalog> { public Catalog addTable(Table table) { checkArgument(table != null, "You must specify a 'table'."); checkArgument(!containsTable(table.getName()), "Catalog: '" + name + "' already contains a table: '" + table.getName() + "'."); checkArgument(!containsView(table.getName()), "Catalog: '" + name + "' already contains a view: '" + table.getName() + "'."); checkArgument(!table.getColumns().isEmpty(), "Table: '" + table.getName() + "' doesn't contain any columns."); checkArgument(!table.getIdentityColumns().isEmpty(), "Table: '" + table.getName() + "' has no identity columns."); tables.add(table); table.setParent(this); return this; } Catalog(String name); }
Catalog implements Copyable<Catalog> { public Catalog addTable(Table table) { checkArgument(table != null, "You must specify a 'table'."); checkArgument(!containsTable(table.getName()), "Catalog: '" + name + "' already contains a table: '" + table.getName() + "'."); checkArgument(!containsView(table.getName()), "Catalog: '" + name + "' already contains a view: '" + table.getName() + "'."); checkArgument(!table.getColumns().isEmpty(), "Table: '" + table.getName() + "' doesn't contain any columns."); checkArgument(!table.getIdentityColumns().isEmpty(), "Table: '" + table.getName() + "' has no identity columns."); tables.add(table); table.setParent(this); return this; } Catalog(String name); Catalog addTable(Table table); boolean containsTable(String tableName); Table getTable(String tableName); Table removeTable(String tableName); Catalog addView(View view); boolean containsView(String viewName); View getView(String viewName); View removeView(String viewName); Catalog addSequence(Sequence sequence); Sequence removeSequence(String sequenceName); ImmutableSet<Table> getTables(); ImmutableSet<View> getViews(); ImmutableSet<ForeignKey> getForeignKeys(); ImmutableSet<Index> getIndexes(); @Override Catalog copy(); @Override String toString(); Set<String> getTablesReferencingTable(String tableName); }
Catalog implements Copyable<Catalog> { public Catalog addTable(Table table) { checkArgument(table != null, "You must specify a 'table'."); checkArgument(!containsTable(table.getName()), "Catalog: '" + name + "' already contains a table: '" + table.getName() + "'."); checkArgument(!containsView(table.getName()), "Catalog: '" + name + "' already contains a view: '" + table.getName() + "'."); checkArgument(!table.getColumns().isEmpty(), "Table: '" + table.getName() + "' doesn't contain any columns."); checkArgument(!table.getIdentityColumns().isEmpty(), "Table: '" + table.getName() + "' has no identity columns."); tables.add(table); table.setParent(this); return this; } Catalog(String name); Catalog addTable(Table table); boolean containsTable(String tableName); Table getTable(String tableName); Table removeTable(String tableName); Catalog addView(View view); boolean containsView(String viewName); View getView(String viewName); View removeView(String viewName); Catalog addSequence(Sequence sequence); Sequence removeSequence(String sequenceName); ImmutableSet<Table> getTables(); ImmutableSet<View> getViews(); ImmutableSet<ForeignKey> getForeignKeys(); ImmutableSet<Index> getIndexes(); @Override Catalog copy(); @Override String toString(); Set<String> getTablesReferencingTable(String tableName);  }