1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.api.identity.personal;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.core.api.CoreConstants;
20 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
21 import org.kuali.rice.core.api.mo.ModelBuilder;
22 import org.kuali.rice.kim.api.KimApiConstants;
23 import org.w3c.dom.Element;
24
25 import javax.xml.bind.annotation.XmlAccessType;
26 import javax.xml.bind.annotation.XmlAccessorType;
27 import javax.xml.bind.annotation.XmlAnyElement;
28 import javax.xml.bind.annotation.XmlElement;
29 import javax.xml.bind.annotation.XmlRootElement;
30 import javax.xml.bind.annotation.XmlType;
31 import java.io.Serializable;
32 import java.util.Collection;
33
34 @XmlRootElement(name = EntityEthnicity.Constants.ROOT_ELEMENT_NAME)
35 @XmlAccessorType(XmlAccessType.NONE)
36 @XmlType(name = EntityEthnicity.Constants.TYPE_NAME, propOrder = {
37 EntityEthnicity.Elements.ID,
38 EntityEthnicity.Elements.ENTITY_ID,
39 EntityEthnicity.Elements.ETHNICITY_CODE,
40 EntityEthnicity.Elements.ETHNICITY_CODE_UNMASKED,
41 EntityEthnicity.Elements.SUB_ETHNICITY_CODE,
42 EntityEthnicity.Elements.SUB_ETHNICITY_CODE_UNMASKED,
43 EntityEthnicity.Elements.SUPPRESS_PERSONAL,
44 CoreConstants.CommonElements.VERSION_NUMBER,
45 CoreConstants.CommonElements.OBJECT_ID,
46 CoreConstants.CommonElements.FUTURE_ELEMENTS
47 })
48 public final class EntityEthnicity extends AbstractDataTransferObject
49 implements EntityEthnicityContract
50 {
51
52 @XmlElement(name = Elements.ENTITY_ID, required = false)
53 private final String entityId;
54 @XmlElement(name = Elements.ETHNICITY_CODE, required = false)
55 private final String ethnicityCode;
56 @XmlElement(name = Elements.ETHNICITY_CODE_UNMASKED, required = false)
57 private final String ethnicityCodeUnmasked;
58 @XmlElement(name = Elements.SUB_ETHNICITY_CODE, required = false)
59 private final String subEthnicityCode;
60 @XmlElement(name = Elements.SUB_ETHNICITY_CODE_UNMASKED, required = false)
61 private final String subEthnicityCodeUnmasked;
62 @XmlElement(name = Elements.SUPPRESS_PERSONAL, required = false)
63 private final boolean suppressPersonal;
64 @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
65 private final Long versionNumber;
66 @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
67 private final String objectId;
68 @XmlElement(name = Elements.ID, required = false)
69 private final String id;
70 @SuppressWarnings("unused")
71 @XmlAnyElement
72 private final Collection<Element> _futureElements = null;
73
74
75
76
77
78 private EntityEthnicity() {
79 this.entityId = null;
80 this.ethnicityCode = null;
81 this.ethnicityCodeUnmasked = null;
82 this.subEthnicityCode = null;
83 this.subEthnicityCodeUnmasked = null;
84 this.suppressPersonal = false;
85 this.versionNumber = null;
86 this.objectId = null;
87 this.id = null;
88 }
89
90 private EntityEthnicity(Builder builder) {
91 this.entityId = builder.getEntityId();
92 this.ethnicityCode = builder.getEthnicityCode();
93 this.ethnicityCodeUnmasked = builder.getEthnicityCodeUnmasked();
94 this.subEthnicityCode = builder.getSubEthnicityCode();
95 this.subEthnicityCodeUnmasked = builder.getSubEthnicityCodeUnmasked();
96 this.suppressPersonal = builder.isSuppressPersonal();
97 this.versionNumber = builder.getVersionNumber();
98 this.objectId = builder.getObjectId();
99 this.id = builder.getId();
100 }
101
102 @Override
103 public String getEntityId() {
104 return this.entityId;
105 }
106
107 @Override
108 public String getEthnicityCode() {
109 return this.ethnicityCode;
110 }
111
112 @Override
113 public String getEthnicityCodeUnmasked() {
114 return this.ethnicityCodeUnmasked;
115 }
116
117 @Override
118 public String getSubEthnicityCode() {
119 return this.subEthnicityCode;
120 }
121
122 @Override
123 public String getSubEthnicityCodeUnmasked() {
124 return this.subEthnicityCodeUnmasked;
125 }
126
127 @Override
128 public boolean isSuppressPersonal() {
129 return this.suppressPersonal;
130 }
131
132 @Override
133 public Long getVersionNumber() {
134 return this.versionNumber;
135 }
136
137 @Override
138 public String getObjectId() {
139 return this.objectId;
140 }
141
142 @Override
143 public String getId() {
144 return this.id;
145 }
146
147
148
149
150
151 public final static class Builder
152 implements Serializable, ModelBuilder, EntityEthnicityContract
153 {
154
155 private String entityId;
156 private String ethnicityCode;
157 private String subEthnicityCode;
158 private boolean suppressPersonal;
159 private Long versionNumber;
160 private String objectId;
161 private String id;
162
163 private Builder() { }
164
165 public static Builder create() {
166 return new Builder();
167 }
168
169 public static Builder create(EntityEthnicityContract contract) {
170 if (contract == null) {
171 throw new IllegalArgumentException("contract was null");
172 }
173 Builder builder = create();
174 builder.setEntityId(contract.getEntityId());
175 builder.setEthnicityCode(contract.getEthnicityCodeUnmasked());
176 builder.setSubEthnicityCode(contract.getSubEthnicityCodeUnmasked());
177 builder.setSuppressPersonal(contract.isSuppressPersonal());
178 builder.setVersionNumber(contract.getVersionNumber());
179 builder.setObjectId(contract.getObjectId());
180 builder.setId(contract.getId());
181 return builder;
182 }
183
184 @Override
185 public EntityEthnicity build() {
186 return new EntityEthnicity(this);
187 }
188
189 @Override
190 public String getEntityId() {
191 return this.entityId;
192 }
193
194 @Override
195 public String getEthnicityCode() {
196 if (isSuppressPersonal()) {
197 return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK;
198 }
199 return this.ethnicityCode;
200 }
201
202 @Override
203 public String getEthnicityCodeUnmasked() {
204 return this.ethnicityCode;
205 }
206
207 @Override
208 public String getSubEthnicityCode() {
209 if (isSuppressPersonal()) {
210 return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK;
211 }
212 return this.subEthnicityCode;
213 }
214
215 @Override
216 public String getSubEthnicityCodeUnmasked() {
217 return this.subEthnicityCode;
218 }
219
220 @Override
221 public boolean isSuppressPersonal() {
222 return this.suppressPersonal;
223 }
224
225 @Override
226 public Long getVersionNumber() {
227 return this.versionNumber;
228 }
229
230 @Override
231 public String getObjectId() {
232 return this.objectId;
233 }
234
235 @Override
236 public String getId() {
237 return this.id;
238 }
239
240 public void setEntityId(String entityId) {
241 this.entityId = entityId;
242 }
243
244 public void setEthnicityCode(String ethnicityCode) {
245 this.ethnicityCode = ethnicityCode;
246 }
247
248 public void setSubEthnicityCode(String subEthnicityCode) {
249 this.subEthnicityCode = subEthnicityCode;
250 }
251
252 private void setSuppressPersonal(boolean suppressPersonal) {
253 this.suppressPersonal = suppressPersonal;
254 }
255
256 public void setVersionNumber(Long versionNumber) {
257 this.versionNumber = versionNumber;
258 }
259
260 public void setObjectId(String objectId) {
261 this.objectId = objectId;
262 }
263
264 public void setId(String id) {
265 if (StringUtils.isWhitespace(id)) {
266 throw new IllegalArgumentException("id is blank");
267 }
268 this.id = id;
269 }
270
271 }
272
273
274
275
276
277
278 static class Constants {
279
280 final static String ROOT_ELEMENT_NAME = "entityEthnicity";
281 final static String TYPE_NAME = "EntityEthnicityType";
282 }
283
284
285
286
287
288
289 static class Elements {
290
291 final static String ENTITY_ID = "entityId";
292 final static String ETHNICITY_CODE = "ethnicityCode";
293 final static String ETHNICITY_CODE_UNMASKED = "ethnicityCodeUnmasked";
294 final static String SUB_ETHNICITY_CODE = "subEthnicityCode";
295 final static String SUB_ETHNICITY_CODE_UNMASKED = "subEthnicityCodeUnmasked";
296 final static String SUPPRESS_PERSONAL = "suppressPersonal";
297 final static String ID = "id";
298
299 }
300
301 }