1 | |
package org.kuali.rice.kim.api.identity.residency; |
2 | |
|
3 | |
import org.apache.commons.lang.StringUtils; |
4 | |
import org.apache.commons.lang.builder.EqualsBuilder; |
5 | |
import org.apache.commons.lang.builder.HashCodeBuilder; |
6 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
7 | |
import org.kuali.rice.core.api.CoreConstants; |
8 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
9 | |
import org.kuali.rice.core.api.mo.ModelObjectComplete; |
10 | |
import org.w3c.dom.Element; |
11 | |
|
12 | |
import javax.xml.bind.annotation.XmlAccessType; |
13 | |
import javax.xml.bind.annotation.XmlAccessorType; |
14 | |
import javax.xml.bind.annotation.XmlAnyElement; |
15 | |
import javax.xml.bind.annotation.XmlElement; |
16 | |
import javax.xml.bind.annotation.XmlRootElement; |
17 | |
import javax.xml.bind.annotation.XmlType; |
18 | |
import java.io.Serializable; |
19 | |
import java.util.Collection; |
20 | |
|
21 | |
@XmlRootElement(name = EntityResidency.Constants.ROOT_ELEMENT_NAME) |
22 | |
@XmlAccessorType(XmlAccessType.NONE) |
23 | |
@XmlType(name = EntityResidency.Constants.TYPE_NAME, propOrder = { |
24 | |
EntityResidency.Elements.ID, |
25 | |
EntityResidency.Elements.ENTITY_ID, |
26 | |
EntityResidency.Elements.DETERMINATION_METHOD, |
27 | |
EntityResidency.Elements.IN_STATE, |
28 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
29 | |
CoreConstants.CommonElements.OBJECT_ID, |
30 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
31 | |
}) |
32 | 6 | public final class EntityResidency |
33 | |
implements ModelObjectComplete, EntityResidencyContract |
34 | |
{ |
35 | |
|
36 | |
@XmlElement(name = Elements.ENTITY_ID, required = false) |
37 | |
private final String entityId; |
38 | |
@XmlElement(name = Elements.DETERMINATION_METHOD, required = false) |
39 | |
private final String determinationMethod; |
40 | |
@XmlElement(name = Elements.IN_STATE, required = false) |
41 | |
private final String inState; |
42 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
43 | |
private final Long versionNumber; |
44 | |
@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false) |
45 | |
private final String objectId; |
46 | |
@XmlElement(name = Elements.ID, required = false) |
47 | |
private final String id; |
48 | 10 | @SuppressWarnings("unused") |
49 | |
@XmlAnyElement |
50 | |
private final Collection<Element> _futureElements = null; |
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | 4 | private EntityResidency() { |
57 | 4 | this.entityId = null; |
58 | 4 | this.determinationMethod = null; |
59 | 4 | this.inState = null; |
60 | 4 | this.versionNumber = null; |
61 | 4 | this.objectId = null; |
62 | 4 | this.id = null; |
63 | 4 | } |
64 | |
|
65 | 6 | private EntityResidency(Builder builder) { |
66 | 6 | this.entityId = builder.getEntityId(); |
67 | 6 | this.determinationMethod = builder.getDeterminationMethod(); |
68 | 6 | this.inState = builder.getInState(); |
69 | 6 | this.versionNumber = builder.getVersionNumber(); |
70 | 6 | this.objectId = builder.getObjectId(); |
71 | 6 | this.id = builder.getId(); |
72 | 6 | } |
73 | |
|
74 | |
@Override |
75 | |
public String getEntityId() { |
76 | 4 | return this.entityId; |
77 | |
} |
78 | |
|
79 | |
@Override |
80 | |
public String getDeterminationMethod() { |
81 | 4 | return this.determinationMethod; |
82 | |
} |
83 | |
|
84 | |
@Override |
85 | |
public String getInState() { |
86 | 4 | return this.inState; |
87 | |
} |
88 | |
|
89 | |
@Override |
90 | |
public Long getVersionNumber() { |
91 | 4 | return this.versionNumber; |
92 | |
} |
93 | |
|
94 | |
@Override |
95 | |
public String getObjectId() { |
96 | 4 | return this.objectId; |
97 | |
} |
98 | |
|
99 | |
@Override |
100 | |
public String getId() { |
101 | 4 | return this.id; |
102 | |
} |
103 | |
|
104 | |
@Override |
105 | |
public int hashCode() { |
106 | 0 | return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
107 | |
} |
108 | |
|
109 | |
@Override |
110 | |
public boolean equals(Object object) { |
111 | 5 | return EqualsBuilder.reflectionEquals(object, this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
112 | |
} |
113 | |
|
114 | |
@Override |
115 | |
public String toString() { |
116 | 0 | return ToStringBuilder.reflectionToString(this); |
117 | |
} |
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | 4 | public final static class Builder |
125 | |
implements Serializable, ModelBuilder, EntityResidencyContract |
126 | |
{ |
127 | |
|
128 | |
private String entityId; |
129 | |
private String determinationMethod; |
130 | |
private String inState; |
131 | |
private Long versionNumber; |
132 | |
private String objectId; |
133 | |
private String id; |
134 | |
|
135 | 8 | private Builder() { } |
136 | |
|
137 | |
public static Builder create() { |
138 | 8 | return new Builder(); |
139 | |
} |
140 | |
|
141 | |
public static Builder create(EntityResidencyContract contract) { |
142 | 5 | if (contract == null) { |
143 | 0 | throw new IllegalArgumentException("contract was null"); |
144 | |
} |
145 | 5 | Builder builder = create(); |
146 | 5 | builder.setEntityId(contract.getEntityId()); |
147 | 5 | builder.setDeterminationMethod(contract.getDeterminationMethod()); |
148 | 5 | builder.setInState(contract.getInState()); |
149 | 5 | builder.setVersionNumber(contract.getVersionNumber()); |
150 | 5 | builder.setObjectId(contract.getObjectId()); |
151 | 5 | builder.setId(contract.getId()); |
152 | 5 | return builder; |
153 | |
} |
154 | |
|
155 | |
public EntityResidency build() { |
156 | 6 | return new EntityResidency(this); |
157 | |
} |
158 | |
|
159 | |
@Override |
160 | |
public String getEntityId() { |
161 | 6 | return this.entityId; |
162 | |
} |
163 | |
|
164 | |
@Override |
165 | |
public String getDeterminationMethod() { |
166 | 6 | return this.determinationMethod; |
167 | |
} |
168 | |
|
169 | |
@Override |
170 | |
public String getInState() { |
171 | 6 | return this.inState; |
172 | |
} |
173 | |
|
174 | |
@Override |
175 | |
public Long getVersionNumber() { |
176 | 6 | return this.versionNumber; |
177 | |
} |
178 | |
|
179 | |
@Override |
180 | |
public String getObjectId() { |
181 | 6 | return this.objectId; |
182 | |
} |
183 | |
|
184 | |
@Override |
185 | |
public String getId() { |
186 | 6 | return this.id; |
187 | |
} |
188 | |
|
189 | |
public void setEntityId(String entityId) { |
190 | 5 | this.entityId = entityId; |
191 | 5 | } |
192 | |
|
193 | |
public void setDeterminationMethod(String determinationMethod) { |
194 | 5 | this.determinationMethod = determinationMethod; |
195 | 5 | } |
196 | |
|
197 | |
public void setInState(String inState) { |
198 | 5 | this.inState = inState; |
199 | 5 | } |
200 | |
|
201 | |
public void setVersionNumber(Long versionNumber) { |
202 | 5 | this.versionNumber = versionNumber; |
203 | 5 | } |
204 | |
|
205 | |
public void setObjectId(String objectId) { |
206 | 5 | this.objectId = objectId; |
207 | 5 | } |
208 | |
|
209 | |
public void setId(String id) { |
210 | 6 | if (StringUtils.isWhitespace(id)) { |
211 | 1 | throw new IllegalArgumentException("id is blank"); |
212 | |
} |
213 | 5 | this.id = id; |
214 | 5 | } |
215 | |
|
216 | |
} |
217 | |
|
218 | |
|
219 | |
|
220 | |
|
221 | |
|
222 | |
|
223 | 0 | static class Constants { |
224 | |
|
225 | |
final static String ROOT_ELEMENT_NAME = "entityResidency"; |
226 | |
final static String TYPE_NAME = "entityResidencyType"; |
227 | 1 | final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] {CoreConstants.CommonElements.FUTURE_ELEMENTS }; |
228 | |
|
229 | |
} |
230 | |
|
231 | |
|
232 | |
|
233 | |
|
234 | |
|
235 | |
|
236 | 0 | static class Elements { |
237 | |
|
238 | |
final static String ENTITY_ID = "entityId"; |
239 | |
final static String DETERMINATION_METHOD = "determinationMethod"; |
240 | |
final static String IN_STATE = "inState"; |
241 | |
final static String ID = "id"; |
242 | |
|
243 | |
} |
244 | |
|
245 | |
} |