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

Last change on this file since 52 was 52, checked in by ruud, 14 months ago

Fixed small issues in domaineditor.

File size: 2.1 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 /**
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}
Note: See TracBrowser for help on using the repository browser.