1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.api.identity.affiliation; |
17 | |
|
18 | |
import java.io.Serializable; |
19 | |
import java.util.Collection; |
20 | |
import javax.xml.bind.annotation.XmlAccessType; |
21 | |
import javax.xml.bind.annotation.XmlAccessorType; |
22 | |
import javax.xml.bind.annotation.XmlAnyElement; |
23 | |
import javax.xml.bind.annotation.XmlElement; |
24 | |
import javax.xml.bind.annotation.XmlRootElement; |
25 | |
import javax.xml.bind.annotation.XmlType; |
26 | |
|
27 | |
import org.apache.commons.lang.StringUtils; |
28 | |
import org.kuali.rice.core.api.CoreConstants; |
29 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
30 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
31 | |
import org.w3c.dom.Element; |
32 | |
|
33 | |
@XmlRootElement(name = EntityAffiliationType.Constants.ROOT_ELEMENT_NAME) |
34 | |
@XmlAccessorType(XmlAccessType.NONE) |
35 | |
@XmlType(name = EntityAffiliationType.Constants.TYPE_NAME, propOrder = { |
36 | |
EntityAffiliationType.Elements.CODE, |
37 | |
EntityAffiliationType.Elements.NAME, |
38 | |
EntityAffiliationType.Elements.SORT_CODE, |
39 | |
EntityAffiliationType.Elements.ACTIVE, |
40 | |
EntityAffiliationType.Elements.EMPLOYMENT_AFFILIATION_TYPE, |
41 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
42 | |
CoreConstants.CommonElements.OBJECT_ID, |
43 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
44 | |
}) |
45 | 0 | public final class EntityAffiliationType extends AbstractDataTransferObject |
46 | |
implements EntityAffiliationTypeContract |
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.EMPLOYMENT_AFFILIATION_TYPE, required = false) |
55 | |
private final boolean employmentAffiliationType; |
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 EntityAffiliationType() { |
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.employmentAffiliationType = false; |
78 | 0 | } |
79 | |
|
80 | 0 | private EntityAffiliationType(Builder builder) { |
81 | 0 | this.name = builder.getName(); |
82 | 0 | this.code = builder.getCode(); |
83 | 0 | this.sortCode = builder.getSortCode(); |
84 | 0 | this.employmentAffiliationType = builder.isEmploymentAffiliationType(); |
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 isEmploymentAffiliationType() { |
107 | 0 | return this.employmentAffiliationType; |
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, EntityAffiliationTypeContract |
131 | |
{ |
132 | |
|
133 | |
private String name; |
134 | |
private String code; |
135 | |
private String sortCode; |
136 | |
private boolean employmentAffiliationType; |
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(EntityAffiliationTypeContract contract) { |
150 | 0 | if (contract == null) { |
151 | 0 | throw new IllegalArgumentException("contract was null"); |
152 | |
} |
153 | |
|
154 | 0 | Builder builder = create(contract.getCode()); |
155 | 0 | builder.setName(contract.getName()); |
156 | 0 | builder.setSortCode(contract.getSortCode()); |
157 | 0 | builder.setEmploymentAffiliationType(contract.isEmploymentAffiliationType()); |
158 | 0 | builder.setVersionNumber(contract.getVersionNumber()); |
159 | 0 | builder.setObjectId(contract.getObjectId()); |
160 | 0 | builder.setActive(contract.isActive()); |
161 | 0 | return builder; |
162 | |
} |
163 | |
|
164 | |
public EntityAffiliationType build() { |
165 | 0 | return new EntityAffiliationType(this); |
166 | |
} |
167 | |
|
168 | |
@Override |
169 | |
public String getName() { |
170 | 0 | return this.name; |
171 | |
} |
172 | |
|
173 | |
@Override |
174 | |
public String getCode() { |
175 | 0 | return this.code; |
176 | |
} |
177 | |
|
178 | |
@Override |
179 | |
public String getSortCode() { |
180 | 0 | return this.sortCode; |
181 | |
} |
182 | |
|
183 | |
@Override |
184 | |
public boolean isEmploymentAffiliationType() { |
185 | 0 | return this.employmentAffiliationType; |
186 | |
} |
187 | |
|
188 | |
@Override |
189 | |
public Long getVersionNumber() { |
190 | 0 | return this.versionNumber; |
191 | |
} |
192 | |
|
193 | |
@Override |
194 | |
public String getObjectId() { |
195 | 0 | return this.objectId; |
196 | |
} |
197 | |
|
198 | |
@Override |
199 | |
public boolean isActive() { |
200 | 0 | return this.active; |
201 | |
} |
202 | |
|
203 | |
public void setName(String name) { |
204 | 0 | this.name = name; |
205 | 0 | } |
206 | |
|
207 | |
public void setCode(String code) { |
208 | 0 | if (StringUtils.isWhitespace(code)) { |
209 | 0 | throw new IllegalArgumentException("code is empty"); |
210 | |
} |
211 | 0 | this.code = code; |
212 | 0 | } |
213 | |
|
214 | |
public void setSortCode(String sortCode) { |
215 | 0 | this.sortCode = sortCode; |
216 | 0 | } |
217 | |
|
218 | |
public void setEmploymentAffiliationType(boolean employmentAffiliationType) { |
219 | 0 | this.employmentAffiliationType = employmentAffiliationType; |
220 | 0 | } |
221 | |
|
222 | |
public void setVersionNumber(Long versionNumber) { |
223 | 0 | this.versionNumber = versionNumber; |
224 | 0 | } |
225 | |
|
226 | |
public void setObjectId(String objectId) { |
227 | 0 | this.objectId = objectId; |
228 | 0 | } |
229 | |
|
230 | |
public void setActive(boolean active) { |
231 | 0 | this.active = active; |
232 | 0 | } |
233 | |
|
234 | |
} |
235 | |
|
236 | |
|
237 | |
|
238 | |
|
239 | |
|
240 | |
|
241 | 0 | static class Constants { |
242 | |
final static String ROOT_ELEMENT_NAME = "entityAffiliationType"; |
243 | |
final static String TYPE_NAME = "entityAffiliationTypeType"; |
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 EMPLOYMENT_AFFILIATION_TYPE = "employmentAffiliationType"; |
258 | |
|
259 | |
} |
260 | |
|
261 | |
} |