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