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