-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathAbstractTableColumn.java
More file actions
76 lines (63 loc) · 1.91 KB
/
AbstractTableColumn.java
File metadata and controls
76 lines (63 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package sqlancer.common.schema;
public class AbstractTableColumn<T extends AbstractTable<?, ?, ?>, U> implements Comparable<AbstractTableColumn<T, U>> {
private final String name;
private final U type;
private T table;
public AbstractTableColumn(String name, T table, U type) {
this.name = name;
this.table = table;
this.type = type;
}
public String getName() {
return name;
}
public String getFullQualifiedName() {
if (table == null) {
return getName();
} else {
return table.getName() + "." + getName();
}
}
public void setTable(T table) {
this.table = table;
}
public T getTable() {
return table;
}
public U getType() {
return type;
}
@Override
public String toString() {
if (table == null) {
return String.format("%s: %s", getName(), getType());
} else {
return String.format("%s.%s: %s", table.getName(), getName(), getType());
}
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof AbstractTableColumn)) {
return false;
} else {
@SuppressWarnings("unchecked")
AbstractTableColumn<T, U> c = (AbstractTableColumn<T, U>) obj;
if (c.getTable() == null) {
return getName().equals(c.getName());
}
return table.getName().contentEquals(c.getTable().getName()) && getName().equals(c.getName());
}
}
@Override
public int hashCode() {
return getName().hashCode() + 11 * getType().hashCode();
}
@Override
public int compareTo(AbstractTableColumn<T, U> o) {
if (o.getTable().equals(this.getTable())) {
return getName().compareTo(o.getName());
} else {
return o.getTable().compareTo(getTable());
}
}
}