1
|
package eu.dnetlib.enabling.datasources.common;
|
2
|
|
3
|
import java.io.Serializable;
|
4
|
import java.util.Objects;
|
5
|
|
6
|
import javax.persistence.Embeddable;
|
7
|
import javax.persistence.JoinColumn;
|
8
|
import javax.persistence.ManyToOne;
|
9
|
import javax.persistence.MappedSuperclass;
|
10
|
|
11
|
import com.google.common.collect.ComparisonChain;
|
12
|
|
13
|
/**
|
14
|
* Created by claudio on 13/04/2017.
|
15
|
*/
|
16
|
@Embeddable
|
17
|
@MappedSuperclass
|
18
|
public class ApiParamKey<A extends Api> implements Serializable {
|
19
|
|
20
|
/**
|
21
|
*
|
22
|
*/
|
23
|
protected static final long serialVersionUID = 1640636806392015938L;
|
24
|
|
25
|
@ManyToOne
|
26
|
@JoinColumn(name = "api")
|
27
|
protected A api = null;
|
28
|
|
29
|
protected String param;
|
30
|
|
31
|
public ApiParamKey() {}
|
32
|
|
33
|
public String getParam() {
|
34
|
return param;
|
35
|
}
|
36
|
|
37
|
public ApiParamKey setParam(final String param) {
|
38
|
this.param = param;
|
39
|
return this;
|
40
|
}
|
41
|
|
42
|
public A getApi() {
|
43
|
return api;
|
44
|
}
|
45
|
|
46
|
public void setApi(final A api) {
|
47
|
this.api = api;
|
48
|
}
|
49
|
|
50
|
public int hashCode() {
|
51
|
return Objects.hash(getParam(), getApi().getId());
|
52
|
}
|
53
|
|
54
|
@Override
|
55
|
public boolean equals(final Object o) {
|
56
|
if (this == o) { return true; }
|
57
|
if (o == null || getClass() != o.getClass()) { return false; }
|
58
|
ApiParamKey apk = (ApiParamKey) o;
|
59
|
return ComparisonChain.start()
|
60
|
.compare(getParam(), apk.getParam())
|
61
|
.compare(getApi(), apk.getApi())
|
62
|
.result() == 0;
|
63
|
}
|
64
|
|
65
|
}
|