01: package liquibase.database.structure;
02:
03: import liquibase.database.Database;
04:
05: import java.util.ArrayList;
06: import java.util.List;
07:
08: public class Table implements DatabaseObject, Comparable<Table> {
09:
10: private Database database;
11: private String name;
12: private String remarks;
13: private List<Column> columns = new ArrayList<Column>();
14:
15: public Table(String name) {
16: this .name = name;
17: }
18:
19: public String getName() {
20: return name;
21: }
22:
23: public Database getDatabase() {
24: return database;
25: }
26:
27: public void setDatabase(Database database) {
28: this .database = database;
29: }
30:
31: public String getRemarks() {
32: return remarks;
33: }
34:
35: public void setRemarks(String remarks) {
36: this .remarks = remarks;
37: }
38:
39: public List<Column> getColumns() {
40: return columns;
41: }
42:
43: public boolean equals(Object o) {
44: if (this == o)
45: return true;
46: if (o == null || getClass() != o.getClass())
47: return false;
48:
49: Table that = (Table) o;
50:
51: return name.equalsIgnoreCase(that.name);
52:
53: }
54:
55: public int hashCode() {
56: return name.toUpperCase().hashCode();
57: }
58:
59: public int compareTo(Table o) {
60: return this .getName().compareTo(o.getName());
61: }
62:
63: public String toString() {
64: return getName();
65: }
66:
67: /**
68: * Returns the column object for the given columnName. If the column does not exist in this table,
69: * return null.
70: */
71: public Column getColumn(String columnName) {
72: for (Column column : getColumns()) {
73: if (column.getName().equalsIgnoreCase(columnName)) {
74: return column;
75: }
76: }
77: return null;
78: }
79: }
|