1 | |
package liquibase.database.structure; |
2 | |
|
3 | |
import liquibase.database.Database; |
4 | |
|
5 | |
import java.util.ArrayList; |
6 | |
import java.util.List; |
7 | |
|
8 | 0 | public class View implements DatabaseObject, Comparable<View> { |
9 | |
private Database database; |
10 | |
private String name; |
11 | |
private String schema; |
12 | 0 | private List<Column> columns = new ArrayList<Column>(); |
13 | |
private String definition; |
14 | |
|
15 | |
private String rawCatalogName; |
16 | |
private String rawSchemaName; |
17 | |
|
18 | 0 | public View(String name) { |
19 | 0 | this.name = name; |
20 | 0 | } |
21 | |
|
22 | 0 | public View() { |
23 | 0 | } |
24 | |
|
25 | |
public DatabaseObject[] getContainingObjects() { |
26 | 0 | return new DatabaseObject[] { getDatabase() }; |
27 | |
} |
28 | |
|
29 | |
public Database getDatabase() { |
30 | 0 | return database; |
31 | |
} |
32 | |
|
33 | |
public void setDatabase(Database database) { |
34 | 0 | this.database = database; |
35 | 0 | } |
36 | |
|
37 | |
public String getName() { |
38 | 0 | return name; |
39 | |
} |
40 | |
|
41 | |
public void setName(String name) { |
42 | 0 | this.name = name; |
43 | 0 | } |
44 | |
|
45 | |
public List<Column> getColumns() { |
46 | 0 | return columns; |
47 | |
} |
48 | |
|
49 | |
public void addColumn(Column column) { |
50 | 0 | columns.add(column); |
51 | 0 | } |
52 | |
|
53 | |
public String getDefinition() { |
54 | 0 | return definition; |
55 | |
} |
56 | |
|
57 | |
public void setDefinition(String definition) { |
58 | 0 | this.definition = definition; |
59 | 0 | } |
60 | |
|
61 | |
@Override |
62 | |
public boolean equals(Object o) { |
63 | 0 | if (this == o) |
64 | 0 | return true; |
65 | 0 | if (o == null || getClass() != o.getClass()) |
66 | 0 | return false; |
67 | |
|
68 | 0 | View view = (View) o; |
69 | |
|
70 | 0 | return name.equalsIgnoreCase(view.name); |
71 | |
|
72 | |
} |
73 | |
|
74 | |
@Override |
75 | |
public int hashCode() { |
76 | 0 | return name.toUpperCase().hashCode(); |
77 | |
} |
78 | |
|
79 | |
public int compareTo(View o) { |
80 | 0 | return this.getName().compareTo(o.getName()); |
81 | |
} |
82 | |
|
83 | |
@Override |
84 | |
public String toString() { |
85 | 0 | String viewStr = getName() + " ("; |
86 | 0 | for (int i = 0; i < columns.size(); i++) { |
87 | 0 | if (i > 0) { |
88 | 0 | viewStr += "," + columns.get(i); |
89 | |
} else { |
90 | 0 | viewStr += columns.get(i); |
91 | |
} |
92 | |
} |
93 | 0 | viewStr += ")"; |
94 | 0 | return viewStr; |
95 | |
} |
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
public String getSchema() { |
101 | 0 | return schema; |
102 | |
} |
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
public void setSchema(String schema) { |
109 | 0 | this.schema = schema; |
110 | 0 | } |
111 | |
|
112 | |
public String getRawCatalogName() { |
113 | 0 | return rawCatalogName; |
114 | |
} |
115 | |
|
116 | |
public void setRawCatalogName(String rawCatalogName) { |
117 | 0 | this.rawCatalogName = rawCatalogName; |
118 | 0 | } |
119 | |
|
120 | |
public String getRawSchemaName() { |
121 | 0 | return rawSchemaName; |
122 | |
} |
123 | |
|
124 | |
public void setRawSchemaName(String rawSchemaName) { |
125 | 0 | this.rawSchemaName = rawSchemaName; |
126 | 0 | } |
127 | |
} |