Changeset 887 for MetadataBeans/trunk/src/main/java/org/eobjects/metamodel/schema/MutableSchema.java
- Timestamp:
- 02/04/10 21:56:24 (2 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
MetadataBeans/trunk/src/main/java/org/eobjects/metamodel/schema/MutableSchema.java
r886 r887 28 28 import org.apache.commons.lang.builder.ToStringStyle; 29 29 30 /** 31 * Represents a schema and it's metadata. Schemas represent a collection of 32 * tables. 33 * 34 * @see Table 35 */ 36 public class Schema implements Serializable, Comparable<Schema> { 30 public class MutableSchema implements Serializable, Schema { 37 31 38 32 private static final long serialVersionUID = 4465197783868238863L; … … 41 35 protected List<Table> _tables = new ArrayList<Table>(); 42 36 43 public Schema() {44 } 45 46 public Schema(String name) {37 public MutableSchema() { 38 } 39 40 public MutableSchema(String name) { 47 41 this(); 48 42 _name = name; 49 43 } 50 44 51 public Schema(String name, Table... tables) {45 public MutableSchema(String name, Table... tables) { 52 46 this(name); 53 47 setTables(tables); … … 57 51 * @return the name of the schema 58 52 */ 53 @Override 59 54 public String getName() { 60 55 return _name; … … 64 59 _name = name; 65 60 for (Table table : _tables) { 66 table.fireSchemaChanged(); 61 if (table instanceof MutableTable) { 62 ((MutableTable) table).fireSchemaChanged(); 63 } 67 64 } 68 65 return this; … … 72 69 * @return the number of tables that reside in the schema 73 70 */ 71 @Override 74 72 public int getTableCount() { 75 73 return _tables.size(); 76 74 } 77 75 76 @Override 78 77 public int getTableCount(TableType type) { 79 78 return getTables(type).length; … … 83 82 * @return the tables that reside in the schema 84 83 */ 84 @Override 85 85 public Table[] getTables() { 86 86 return _tables.toArray(new Table[_tables.size()]); 87 87 } 88 88 89 @Override 89 90 public Table[] getTables(TableType type) { 90 91 List<Table> result = new ArrayList<Table>(); … … 113 114 } 114 115 115 public Schema addTable(Table table) {116 public MutableSchema addTable(Table table) { 116 117 _tables.add(table); 117 118 return this; … … 131 132 * found. 132 133 */ 134 @Override 133 135 public Table getTableByName(String tableName) { 134 136 if (tableName != null) { … … 157 159 } 158 160 161 @Override 159 162 public Relationship[] getRelationships() { 160 163 List<Relationship> result = new ArrayList<Relationship>(); 161 164 for (Table table : _tables) { 162 165 Relationship[] relations = table.getRelationships(); 163 for (int i = 0; i < relations.length; i++) { 164 Relationship relation = relations[i]; 166 for (Relationship relation : relations) { 165 167 boolean found = false; 166 168 for (Relationship existingRelation : result) { … … 179 181 } 180 182 183 @Override 181 184 public int getRelationshipCount() { 182 185 return getRelationships().length; … … 202 205 return true; 203 206 } 204 if (obj instanceof Schema) {207 if (obj instanceof MutableSchema) { 205 208 Schema that = (Schema) obj; 206 209 return new EqualsBuilder().append(this.getName(), that.getName()) … … 210 213 } 211 214 215 @Override 212 216 public int compareTo(Schema that) { 213 217 CompareToBuilder ctb = new CompareToBuilder(); … … 217 221 } 218 222 223 @Override 219 224 public String[] getTableNames() { 220 225 ArrayList<String> result = new ArrayList<String>();
Note: See TracChangeset
for help on using the changeset viewer.
