1 |
|
package liquibase.database.structure; |
2 |
|
|
3 |
|
import liquibase.util.StringUtils; |
4 |
|
|
5 |
|
import java.util.ArrayList; |
6 |
|
import java.util.List; |
7 |
|
|
|
|
| 0% |
Uncovered Elements: 100 (100) |
Complexity: 34 |
Complexity Density: 0.64 |
|
8 |
|
public class UniqueConstraint implements DatabaseObject, Comparable<UniqueConstraint> { |
9 |
|
private String name; |
10 |
|
private Table table; |
11 |
|
private List<String> columns = new ArrayList<String>(); |
12 |
|
|
13 |
|
private boolean deferrable; |
14 |
|
private boolean initiallyDeferred; |
15 |
|
private boolean disabled; |
16 |
|
|
17 |
|
private String tablespace; |
18 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
19 |
0
|
public DatabaseObject[] getContainingObjects() {... |
20 |
0
|
List<DatabaseObject> columns = new ArrayList<DatabaseObject>(); |
21 |
0
|
for (String column : this.columns) { |
22 |
0
|
columns.add(new Column().setName(column).setTable(table)); |
23 |
|
} |
24 |
|
|
25 |
0
|
return columns.toArray(new DatabaseObject[columns.size()]); |
26 |
|
} |
27 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
28 |
0
|
public String getName() {... |
29 |
0
|
return name; |
30 |
|
} |
31 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
32 |
0
|
public void setName(String constraintName) {... |
33 |
0
|
this.name = constraintName; |
34 |
|
} |
35 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
36 |
0
|
public Table getTable() {... |
37 |
0
|
return table; |
38 |
|
} |
39 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
40 |
0
|
public void setTable(Table table) {... |
41 |
0
|
this.table = table; |
42 |
|
} |
43 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
44 |
0
|
public List<String> getColumns() {... |
45 |
0
|
return columns; |
46 |
|
} |
47 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
48 |
0
|
public boolean isDeferrable() {... |
49 |
0
|
return deferrable; |
50 |
|
} |
51 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
52 |
0
|
public void setDeferrable(boolean deferrable) {... |
53 |
0
|
this.deferrable = deferrable; |
54 |
|
} |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
56 |
0
|
public boolean isInitiallyDeferred() {... |
57 |
0
|
return initiallyDeferred; |
58 |
|
} |
59 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
60 |
0
|
public void setInitiallyDeferred(boolean initiallyDeferred) {... |
61 |
0
|
this.initiallyDeferred = initiallyDeferred; |
62 |
|
} |
63 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
64 |
0
|
public String getColumnNames() {... |
65 |
0
|
return StringUtils.join(columns, ", "); |
66 |
|
} |
67 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
68 |
0
|
public void setDisabled(boolean disabled) {... |
69 |
0
|
this.disabled = disabled; |
70 |
|
} |
71 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
72 |
0
|
public boolean isDisabled() {... |
73 |
0
|
return disabled; |
74 |
|
} |
75 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
76 |
0
|
public String getTablespace() {... |
77 |
0
|
return tablespace; |
78 |
|
} |
79 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
80 |
0
|
public void setTablespace(String tablespace) {... |
81 |
0
|
this.tablespace = tablespace; |
82 |
|
} |
83 |
|
|
|
|
| 0% |
Uncovered Elements: 30 (30) |
Complexity: 9 |
Complexity Density: 0.56 |
|
84 |
0
|
@Override... |
85 |
|
public boolean equals(Object o) { |
86 |
0
|
if (this == o) |
87 |
0
|
return true; |
88 |
0
|
if (o == null || getClass() != o.getClass()) |
89 |
0
|
return false; |
90 |
0
|
if (null == this.getColumnNames()) |
91 |
0
|
return false; |
92 |
0
|
UniqueConstraint that = (UniqueConstraint) o; |
93 |
0
|
boolean result = false; |
94 |
0
|
result = !(getColumnNames() != null ? !getColumnNames().equalsIgnoreCase(that.getColumnNames()) : that |
95 |
|
.getColumnNames() != null) |
96 |
|
&& isDeferrable() == that.isDeferrable() |
97 |
|
&& isInitiallyDeferred() == that.isInitiallyDeferred() && isDisabled() == that.isDisabled(); |
98 |
|
|
99 |
|
|
100 |
0
|
if (result) { |
101 |
0
|
if (null == this.getTable()) { |
102 |
0
|
result = null == that.getTable(); |
103 |
0
|
} else if (null == that.getTable()) { |
104 |
0
|
result = false; |
105 |
|
} else { |
106 |
0
|
result = this.getTable().getName().equals(that.getTable().getName()); |
107 |
|
} |
108 |
|
} |
109 |
|
|
110 |
0
|
return result; |
111 |
|
|
112 |
|
} |
113 |
|
|
114 |
|
|
115 |
|
@see |
116 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 5 |
Complexity Density: 0.5 |
|
117 |
0
|
public int compareTo(UniqueConstraint o) {... |
118 |
|
|
119 |
0
|
String thisTableName; |
120 |
0
|
String thatTableName; |
121 |
0
|
thisTableName = null == this.getTable() ? "" : this.getTable().getName(); |
122 |
0
|
thatTableName = null == o.getTable() ? "" : o.getTable().getName(); |
123 |
0
|
int returnValue = thisTableName.compareTo(thatTableName); |
124 |
0
|
if (returnValue == 0) { |
125 |
0
|
returnValue = this.getName().compareTo(o.getName()); |
126 |
|
} |
127 |
0
|
if (returnValue == 0) { |
128 |
0
|
returnValue = this.getColumnNames().compareTo(o.getColumnNames()); |
129 |
|
} |
130 |
0
|
return returnValue; |
131 |
|
} |
132 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
133 |
0
|
@Override... |
134 |
|
public int hashCode() { |
135 |
0
|
int result = 0; |
136 |
0
|
if (this.table != null) { |
137 |
0
|
result = this.table.hashCode(); |
138 |
|
} |
139 |
0
|
if (this.name != null) { |
140 |
0
|
result = 31 * result + this.name.toUpperCase().hashCode(); |
141 |
|
} |
142 |
0
|
if (getColumnNames() != null) { |
143 |
0
|
result = 31 * result + getColumnNames().hashCode(); |
144 |
|
} |
145 |
0
|
return result; |
146 |
|
} |
147 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
148 |
0
|
@Override... |
149 |
|
public String toString() { |
150 |
0
|
return getName() + " on " + getTable().getName() + "(" + getColumnNames() + ")"; |
151 |
|
} |
152 |
|
} |