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