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