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