1 | package geniusweb.references;
|
---|
2 |
|
---|
3 | import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
---|
4 | import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
|
---|
5 | import com.fasterxml.jackson.annotation.JsonCreator;
|
---|
6 | import com.fasterxml.jackson.annotation.JsonProperty;
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * Container holding a partyref with parameters
|
---|
10 | */
|
---|
11 | @JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
|
---|
12 | public class PartyWithParameters {
|
---|
13 |
|
---|
14 | private final PartyRef partyref;
|
---|
15 | private final Parameters parameters;
|
---|
16 |
|
---|
17 | @JsonCreator
|
---|
18 | public PartyWithParameters(@JsonProperty("partyref") PartyRef partyref,
|
---|
19 | @JsonProperty("parameters") Parameters parameters) {
|
---|
20 | this.partyref = partyref;
|
---|
21 | this.parameters = parameters;
|
---|
22 | }
|
---|
23 |
|
---|
24 | public PartyRef getPartyRef() {
|
---|
25 | return partyref;
|
---|
26 | }
|
---|
27 |
|
---|
28 | public Parameters getParameters() {
|
---|
29 | return parameters;
|
---|
30 | }
|
---|
31 |
|
---|
32 | @Override
|
---|
33 | public String toString() {
|
---|
34 | if (parameters.isEmpty())
|
---|
35 | return partyref.toString();
|
---|
36 | return partyref.toString() + parameters.toString();
|
---|
37 | }
|
---|
38 |
|
---|
39 | @Override
|
---|
40 | public int hashCode() {
|
---|
41 | final int prime = 31;
|
---|
42 | int result = 1;
|
---|
43 | result = prime * result
|
---|
44 | + ((parameters == null) ? 0 : parameters.hashCode());
|
---|
45 | result = prime * result
|
---|
46 | + ((partyref == null) ? 0 : partyref.hashCode());
|
---|
47 | return result;
|
---|
48 | }
|
---|
49 |
|
---|
50 | /**
|
---|
51 | *
|
---|
52 | * @param parameters2 the additional parameters
|
---|
53 | * @return this party but with the given parameters added to our parameters
|
---|
54 | */
|
---|
55 | public PartyWithParameters with(Parameters parameters2) {
|
---|
56 | return new PartyWithParameters(partyref, parameters.with(parameters2));
|
---|
57 | }
|
---|
58 |
|
---|
59 | @Override
|
---|
60 | public boolean equals(Object obj) {
|
---|
61 | if (this == obj)
|
---|
62 | return true;
|
---|
63 | if (obj == null)
|
---|
64 | return false;
|
---|
65 | if (getClass() != obj.getClass())
|
---|
66 | return false;
|
---|
67 | PartyWithParameters other = (PartyWithParameters) obj;
|
---|
68 | if (parameters == null) {
|
---|
69 | if (other.parameters != null)
|
---|
70 | return false;
|
---|
71 | } else if (!parameters.equals(other.parameters))
|
---|
72 | return false;
|
---|
73 | if (partyref == null) {
|
---|
74 | if (other.partyref != null)
|
---|
75 | return false;
|
---|
76 | } else if (!partyref.equals(other.partyref))
|
---|
77 | return false;
|
---|
78 | return true;
|
---|
79 | }
|
---|
80 |
|
---|
81 | }
|
---|