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