Revision 47676
Added by Claudio Atzori almost 7 years ago
ApiParamKey.java | ||
---|---|---|
3 | 3 |
import java.io.Serializable; |
4 | 4 |
import java.util.Objects; |
5 | 5 |
import javax.persistence.Embeddable; |
6 |
import javax.persistence.JoinColumn; |
|
7 |
import javax.persistence.ManyToOne; |
|
6 | 8 |
|
9 |
import com.fasterxml.jackson.annotation.JsonIgnore; |
|
10 |
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
|
7 | 11 |
import com.google.common.collect.ComparisonChain; |
8 | 12 |
|
9 | 13 |
/** |
10 | 14 |
* Created by claudio on 13/04/2017. |
11 | 15 |
*/ |
12 | 16 |
@Embeddable |
17 |
@JsonIgnoreProperties(ignoreUnknown = true) |
|
13 | 18 |
public class ApiParamKey implements Serializable { |
14 | 19 |
|
20 |
@JsonIgnore |
|
21 |
@ManyToOne |
|
22 |
@JoinColumn(name = "api") |
|
23 |
private Api api = null; |
|
24 |
|
|
15 | 25 |
private String param; |
16 | 26 |
|
17 |
private String value;
|
|
27 |
public ApiParamKey() {}
|
|
18 | 28 |
|
19 | 29 |
public String getParam() { |
20 | 30 |
return param; |
21 | 31 |
} |
22 | 32 |
|
23 |
public String getValue() { |
|
24 |
return value; |
|
25 |
} |
|
26 |
|
|
27 | 33 |
public ApiParamKey setParam(final String param) { |
28 | 34 |
this.param = param; |
29 | 35 |
return this; |
30 | 36 |
} |
31 | 37 |
|
32 |
public ApiParamKey setValue(final String value) { |
|
33 |
this.value = value; |
|
34 |
return this; |
|
38 |
public Api getApi() { |
|
39 |
return api; |
|
35 | 40 |
} |
36 | 41 |
|
42 |
public void setApi(final Api api) { |
|
43 |
this.api = api; |
|
44 |
} |
|
45 |
|
|
37 | 46 |
@Override |
38 | 47 |
public int hashCode() { |
39 |
return Objects.hash(getParam(), getValue());
|
|
48 |
return Objects.hash(getParam(), getApi().getId());
|
|
40 | 49 |
} |
41 | 50 |
|
42 | 51 |
@Override |
... | ... | |
50 | 59 |
ApiParamKey apk = (ApiParamKey) o; |
51 | 60 |
return ComparisonChain.start() |
52 | 61 |
.compare(getParam(), apk.getParam()) |
53 |
.compare(getValue(), apk.getValue())
|
|
62 |
.compare(getApi(), apk.getApi())
|
|
54 | 63 |
.result() == 0; |
55 | 64 |
} |
65 |
|
|
66 |
|
|
56 | 67 |
} |
Also available in: Unified diff
fine grained operations