Clover Coverage Report - Liquibase Core 2.0.2
Coverage timestamp: Wed Aug 3 2011 19:29:16 EDT
../../../img/srcFileCovDistChart0.png 69% of files have more coverage
53   152   34   2.79
28   119   0.64   19
19     1.79  
1    
 
  UniqueConstraint       Line # 8 53 0% 34 100 0% 0.0
 
No Tests
 
1    package liquibase.database.structure;
2   
3    import liquibase.util.StringUtils;
4   
5    import java.util.ArrayList;
6    import java.util.List;
7   
 
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    // Setting tablespace attribute for UC's index.
17    private String tablespace;
18   
 
19  0 toggle 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   
 
28  0 toggle public String getName() {
29  0 return name;
30    }
31   
 
32  0 toggle public void setName(String constraintName) {
33  0 this.name = constraintName;
34    }
35   
 
36  0 toggle public Table getTable() {
37  0 return table;
38    }
39   
 
40  0 toggle public void setTable(Table table) {
41  0 this.table = table;
42    }
43   
 
44  0 toggle public List<String> getColumns() {
45  0 return columns;
46    }
47   
 
48  0 toggle public boolean isDeferrable() {
49  0 return deferrable;
50    }
51   
 
52  0 toggle public void setDeferrable(boolean deferrable) {
53  0 this.deferrable = deferrable;
54    }
55   
 
56  0 toggle public boolean isInitiallyDeferred() {
57  0 return initiallyDeferred;
58    }
59   
 
60  0 toggle public void setInitiallyDeferred(boolean initiallyDeferred) {
61  0 this.initiallyDeferred = initiallyDeferred;
62    }
63   
 
64  0 toggle public String getColumnNames() {
65  0 return StringUtils.join(columns, ", ");
66    }
67   
 
68  0 toggle public void setDisabled(boolean disabled) {
69  0 this.disabled = disabled;
70    }
71   
 
72  0 toggle public boolean isDisabled() {
73  0 return disabled;
74    }
75   
 
76  0 toggle public String getTablespace() {
77  0 return tablespace;
78    }
79   
 
80  0 toggle public void setTablespace(String tablespace) {
81  0 this.tablespace = tablespace;
82    }
83   
 
84  0 toggle @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    // Need check for nulls here due to NullPointerException using
99    // Postgres
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 java.lang.Comparable#compareTo(java.lang.Object)
116    */
 
117  0 toggle public int compareTo(UniqueConstraint o) {
118    // Need check for nulls here due to NullPointerException using Postgres
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   
 
133  0 toggle @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   
 
148  0 toggle @Override
149    public String toString() {
150  0 return getName() + " on " + getTable().getName() + "(" + getColumnNames() + ")";
151    }
152    }