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