source: references/src/main/java/geniusweb/references/PartyWithParameters.java@ 29

Last change on this file since 29 was 29, checked in by bart, 3 years ago

some minor fixes

File size: 1.8 KB
Line 
1package geniusweb.references;
2
3import com.fasterxml.jackson.annotation.JsonAutoDetect;
4import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
5import com.fasterxml.jackson.annotation.JsonCreator;
6import 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)
12public 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 @Override
51 public boolean equals(Object obj) {
52 if (this == obj)
53 return true;
54 if (obj == null)
55 return false;
56 if (getClass() != obj.getClass())
57 return false;
58 PartyWithParameters other = (PartyWithParameters) obj;
59 if (parameters == null) {
60 if (other.parameters != null)
61 return false;
62 } else if (!parameters.equals(other.parameters))
63 return false;
64 if (partyref == null) {
65 if (other.partyref != null)
66 return false;
67 } else if (!partyref.equals(other.partyref))
68 return false;
69 return true;
70 }
71
72}
Note: See TracBrowser for help on using the repository browser.