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