1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.api.identity.external; |
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.w3c.dom.Element; |
23 | |
|
24 | |
import javax.xml.bind.annotation.XmlAccessType; |
25 | |
import javax.xml.bind.annotation.XmlAccessorType; |
26 | |
import javax.xml.bind.annotation.XmlAnyElement; |
27 | |
import javax.xml.bind.annotation.XmlElement; |
28 | |
import javax.xml.bind.annotation.XmlRootElement; |
29 | |
import javax.xml.bind.annotation.XmlType; |
30 | |
import java.io.Serializable; |
31 | |
import java.util.Collection; |
32 | |
|
33 | |
@XmlRootElement(name = EntityExternalIdentifierType.Constants.ROOT_ELEMENT_NAME) |
34 | |
@XmlAccessorType(XmlAccessType.NONE) |
35 | |
@XmlType(name = EntityExternalIdentifierType.Constants.TYPE_NAME, propOrder = { |
36 | |
EntityExternalIdentifierType.Elements.CODE, |
37 | |
EntityExternalIdentifierType.Elements.NAME, |
38 | |
EntityExternalIdentifierType.Elements.SORT_CODE, |
39 | |
EntityExternalIdentifierType.Elements.ACTIVE, |
40 | |
EntityExternalIdentifierType.Elements.ENCRYPTION_REQUIRED, |
41 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
42 | |
CoreConstants.CommonElements.OBJECT_ID, |
43 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
44 | |
}) |
45 | 0 | public final class EntityExternalIdentifierType extends AbstractDataTransferObject |
46 | |
implements EntityExternalIdentifierTypeContract |
47 | |
{ |
48 | |
@XmlElement(name = Elements.CODE, required = true) |
49 | |
private final String code; |
50 | |
@XmlElement(name = Elements.NAME, required = false) |
51 | |
private final String name; |
52 | |
@XmlElement(name = Elements.SORT_CODE, required = false) |
53 | |
private final String sortCode; |
54 | |
@XmlElement(name = Elements.ENCRYPTION_REQUIRED, required = false) |
55 | |
private final boolean encryptionRequired; |
56 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
57 | |
private final Long versionNumber; |
58 | |
@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false) |
59 | |
private final String objectId; |
60 | |
@XmlElement(name = Elements.ACTIVE, required = false) |
61 | |
private final boolean active; |
62 | 0 | @SuppressWarnings("unused") |
63 | |
@XmlAnyElement |
64 | |
private final Collection<Element> _futureElements = null; |
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | 0 | private EntityExternalIdentifierType() { |
71 | 0 | this.name = null; |
72 | 0 | this.code = null; |
73 | 0 | this.sortCode = null; |
74 | 0 | this.versionNumber = null; |
75 | 0 | this.objectId = null; |
76 | 0 | this.active = false; |
77 | 0 | this.encryptionRequired = false; |
78 | 0 | } |
79 | |
|
80 | 0 | private EntityExternalIdentifierType(Builder builder) { |
81 | 0 | this.name = builder.getName(); |
82 | 0 | this.code = builder.getCode(); |
83 | 0 | this.sortCode = builder.getSortCode(); |
84 | 0 | this.encryptionRequired = builder.isEncryptionRequired(); |
85 | 0 | this.versionNumber = builder.getVersionNumber(); |
86 | 0 | this.objectId = builder.getObjectId(); |
87 | 0 | this.active = builder.isActive(); |
88 | 0 | } |
89 | |
|
90 | |
@Override |
91 | |
public String getName() { |
92 | 0 | return this.name; |
93 | |
} |
94 | |
|
95 | |
@Override |
96 | |
public String getCode() { |
97 | 0 | return this.code; |
98 | |
} |
99 | |
|
100 | |
@Override |
101 | |
public String getSortCode() { |
102 | 0 | return this.sortCode; |
103 | |
} |
104 | |
|
105 | |
@Override |
106 | |
public boolean isEncryptionRequired() { |
107 | 0 | return this.encryptionRequired; |
108 | |
} |
109 | |
|
110 | |
@Override |
111 | |
public Long getVersionNumber() { |
112 | 0 | return this.versionNumber; |
113 | |
} |
114 | |
|
115 | |
@Override |
116 | |
public String getObjectId() { |
117 | 0 | return this.objectId; |
118 | |
} |
119 | |
|
120 | |
@Override |
121 | |
public boolean isActive() { |
122 | 0 | return this.active; |
123 | |
} |
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | 0 | public final static class Builder |
130 | |
implements Serializable, ModelBuilder, EntityExternalIdentifierTypeContract |
131 | |
{ |
132 | |
|
133 | |
private String name; |
134 | |
private String code; |
135 | |
private String sortCode; |
136 | |
private boolean encryptionRequired; |
137 | |
private Long versionNumber; |
138 | |
private String objectId; |
139 | |
private boolean active; |
140 | |
|
141 | 0 | private Builder(String code) { |
142 | 0 | setCode(code); |
143 | 0 | } |
144 | |
|
145 | |
public static Builder create(String code) { |
146 | 0 | return new Builder(code); |
147 | |
} |
148 | |
|
149 | |
public static Builder create(EntityExternalIdentifierTypeContract contract) { |
150 | 0 | if (contract == null) { |
151 | 0 | throw new IllegalArgumentException("contract was null"); |
152 | |
} |
153 | 0 | Builder builder = create(contract.getCode()); |
154 | 0 | builder.setName(contract.getName()); |
155 | 0 | builder.setSortCode(contract.getSortCode()); |
156 | 0 | builder.setEncryptionRequired(contract.isEncryptionRequired()); |
157 | 0 | builder.setVersionNumber(contract.getVersionNumber()); |
158 | 0 | builder.setObjectId(contract.getObjectId()); |
159 | 0 | builder.setActive(contract.isActive()); |
160 | 0 | return builder; |
161 | |
} |
162 | |
|
163 | |
public EntityExternalIdentifierType build() { |
164 | 0 | return new EntityExternalIdentifierType(this); |
165 | |
} |
166 | |
|
167 | |
@Override |
168 | |
public String getName() { |
169 | 0 | return this.name; |
170 | |
} |
171 | |
|
172 | |
@Override |
173 | |
public String getCode() { |
174 | 0 | return this.code; |
175 | |
} |
176 | |
|
177 | |
@Override |
178 | |
public String getSortCode() { |
179 | 0 | return this.sortCode; |
180 | |
} |
181 | |
|
182 | |
@Override |
183 | |
public boolean isEncryptionRequired() { |
184 | 0 | return this.encryptionRequired; |
185 | |
} |
186 | |
|
187 | |
@Override |
188 | |
public Long getVersionNumber() { |
189 | 0 | return this.versionNumber; |
190 | |
} |
191 | |
|
192 | |
@Override |
193 | |
public String getObjectId() { |
194 | 0 | return this.objectId; |
195 | |
} |
196 | |
|
197 | |
@Override |
198 | |
public boolean isActive() { |
199 | 0 | return this.active; |
200 | |
} |
201 | |
|
202 | |
public void setName(String name) { |
203 | 0 | this.name = name; |
204 | 0 | } |
205 | |
|
206 | |
public void setCode(String code) { |
207 | 0 | if (StringUtils.isWhitespace(code)) { |
208 | 0 | throw new IllegalArgumentException("code is empty"); |
209 | |
} |
210 | 0 | this.code = code; |
211 | 0 | } |
212 | |
|
213 | |
public void setSortCode(String sortCode) { |
214 | 0 | this.sortCode = sortCode; |
215 | 0 | } |
216 | |
|
217 | |
public void setEncryptionRequired(boolean encryptionRequired) { |
218 | 0 | this.encryptionRequired = encryptionRequired; |
219 | 0 | } |
220 | |
|
221 | |
public void setVersionNumber(Long versionNumber) { |
222 | 0 | this.versionNumber = versionNumber; |
223 | 0 | } |
224 | |
|
225 | |
public void setObjectId(String objectId) { |
226 | 0 | this.objectId = objectId; |
227 | 0 | } |
228 | |
|
229 | |
public void setActive(boolean active) { |
230 | 0 | this.active = active; |
231 | 0 | } |
232 | |
|
233 | |
} |
234 | |
|
235 | |
|
236 | |
|
237 | |
|
238 | |
|
239 | |
|
240 | 0 | static class Constants { |
241 | |
|
242 | |
final static String ROOT_ELEMENT_NAME = "entityExternalIdentifierType"; |
243 | |
final static String TYPE_NAME = "entityExternalIdentifierTypeType"; |
244 | |
} |
245 | |
|
246 | |
|
247 | |
|
248 | |
|
249 | |
|
250 | |
|
251 | 0 | static class Elements { |
252 | |
|
253 | |
final static String NAME = "name"; |
254 | |
final static String CODE = "code"; |
255 | |
final static String SORT_CODE = "sortCode"; |
256 | |
final static String ACTIVE = "active"; |
257 | |
final static String ENCRYPTION_REQUIRED = "encryptionRequired"; |
258 | |
|
259 | |
} |
260 | |
|
261 | |
} |