Newer
Older
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package it.inaf.oats.ia2.tapschemamanager.datalayer;
import it.inaf.oats.ia2.tapschemamanager.contract.Key;
import it.inaf.oats.ia2.tapschemamanager.contract.KeyColumn;
import it.inaf.oats.ia2.tapschemamanager.contract.TapSchema;
import java.util.Objects;
/**
* The main implementation of {@link KeyColumn}.
*
* @author Sonia Zorba {@literal <zorba at oats.inaf.it>}
*/
public class KeyColumnImpl extends TapSchemaEntityImpl implements KeyColumn {
private static final long serialVersionUID = -3681677723432728327L;
private Key key;
private KeyColumnImpl() {
// for serialization
super();
}
protected KeyColumnImpl(DBWrapper dbWrapper, TapSchema tapSchema, Key key, String fromColumn, String targetColumn) {
super(dbWrapper, tapSchema);
this.key = key;
addProperty(FROM_COLUMN_KEY, new FixedEntityProperty<>(fromColumn));
addProperty(TARGET_COLUMN_KEY, new FixedEntityProperty<>(targetColumn));
addProperty(KEY_ID_KEY, new EditableProperty<>(key.getId(), true));
addProperty(KEY_COLUMN_ID_KEY, new EditableProperty<Long>());
}
@Override
public String getKeyId() {
return getValue(KEY_ID_KEY, String.class);
}
@Override
public void setKeyId(String keyId) {
setValue(KEY_ID_KEY, keyId);
}
@Override
public String getFromColumn() {
return getValue(FROM_COLUMN_KEY, String.class);
}
@Override
public String getTargetColumn() {
return getValue(TARGET_COLUMN_KEY, String.class);
}
@Override
public Long getKeyColumnID() {
return getValue(KEY_COLUMN_ID_KEY, Long.class);
}
@Override
public void setKeyColumnID(Long keyColumnID) {
setValue(KEY_COLUMN_ID_KEY, keyColumnID);
}
@Override
public int hashCode() {
int hash = 3;
hash = 97 * hash + Objects.hashCode(this.key.getFromTableCompleteName());
hash = 97 * hash + Objects.hashCode(this.getFromColumn());
hash = 97 * hash + Objects.hashCode(this.key.getTargetTableCompleteName());
hash = 97 * hash + Objects.hashCode(this.getTargetColumn());
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final KeyColumnImpl other = (KeyColumnImpl) obj;
if (!Objects.equals(this.key.getFromTableCompleteName(), other.key.getFromTableCompleteName())) {
return false;
}
if (!Objects.equals(this.getFromColumn(), other.getFromColumn())) {
return false;
}
if (!Objects.equals(this.key.getTargetTableCompleteName(), other.key.getTargetTableCompleteName())) {
return false;
}
if (!Objects.equals(this.getTargetColumn(), other.getTargetColumn())) {
return false;
}
return true;
}
}