1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.krms.api.repository.type; |
17 | |
|
18 | |
import java.io.Serializable; |
19 | |
import java.util.Collection; |
20 | |
|
21 | |
import javax.xml.bind.annotation.XmlAccessType; |
22 | |
import javax.xml.bind.annotation.XmlAccessorType; |
23 | |
import javax.xml.bind.annotation.XmlAnyElement; |
24 | |
import javax.xml.bind.annotation.XmlElement; |
25 | |
import javax.xml.bind.annotation.XmlRootElement; |
26 | |
import javax.xml.bind.annotation.XmlType; |
27 | |
|
28 | |
import org.apache.commons.lang.StringUtils; |
29 | |
import org.kuali.rice.core.api.CoreConstants; |
30 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
31 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
@XmlRootElement(name = KrmsAttributeDefinition.Constants.ROOT_ELEMENT_NAME) |
41 | |
@XmlAccessorType(XmlAccessType.NONE) |
42 | |
@XmlType(name = KrmsAttributeDefinition.Constants.TYPE_NAME, propOrder = { |
43 | |
KrmsAttributeDefinition.Elements.ID, |
44 | |
KrmsAttributeDefinition.Elements.NAME, |
45 | |
KrmsAttributeDefinition.Elements.NAMESPACE, |
46 | |
KrmsAttributeDefinition.Elements.LABEL, |
47 | |
KrmsAttributeDefinition.Elements.DESCRIPTION, |
48 | |
KrmsAttributeDefinition.Elements.ACTIVE, |
49 | |
KrmsAttributeDefinition.Elements.COMPONENT_NAME, |
50 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
51 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
52 | |
}) |
53 | 0 | public final class KrmsAttributeDefinition extends AbstractDataTransferObject implements KrmsAttributeDefinitionContract { |
54 | |
private static final long serialVersionUID = -6356968810972165031L; |
55 | |
|
56 | |
@XmlElement(name = Elements.ID, required=true) |
57 | |
private final String id; |
58 | |
@XmlElement(name = Elements.NAME, required=true) |
59 | |
private final String name; |
60 | |
@XmlElement(name = Elements.NAMESPACE, required=true) |
61 | |
private final String namespace; |
62 | |
@XmlElement(name = Elements.LABEL, required=false) |
63 | |
private final String label; |
64 | |
@XmlElement(name = Elements.DESCRIPTION, required=false) |
65 | |
private final String description; |
66 | |
@XmlElement(name = Elements.ACTIVE, required=false) |
67 | |
private final boolean active; |
68 | |
@XmlElement(name = Elements.COMPONENT_NAME, required=false) |
69 | |
private final String componentName; |
70 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
71 | |
private final Long versionNumber; |
72 | |
|
73 | 0 | @SuppressWarnings("unused") |
74 | |
@XmlAnyElement |
75 | |
private final Collection<org.w3c.dom.Element> _futureElements = null; |
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | 0 | private KrmsAttributeDefinition() { |
81 | 0 | this.id = null; |
82 | 0 | this.name = null; |
83 | 0 | this.namespace = null; |
84 | 0 | this.label = null; |
85 | 0 | this.description = null; |
86 | 0 | this.active = false; |
87 | 0 | this.componentName = null; |
88 | 0 | this.versionNumber = null; |
89 | 0 | } |
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | 0 | private KrmsAttributeDefinition(Builder builder) { |
98 | 0 | this.id = builder.getId(); |
99 | 0 | this.name = builder.getName(); |
100 | 0 | this.namespace = builder.getNamespace(); |
101 | 0 | this.label = builder.getLabel(); |
102 | 0 | this.description = builder.getDescription(); |
103 | 0 | this.active = builder.isActive(); |
104 | 0 | this.componentName = builder.getComponentName(); |
105 | 0 | this.versionNumber = builder.getVersionNumber(); |
106 | 0 | } |
107 | |
|
108 | |
public String getId() { |
109 | 0 | return this.id; |
110 | |
} |
111 | |
|
112 | |
public String getName() { |
113 | 0 | return this.name; |
114 | |
} |
115 | |
|
116 | |
public String getNamespace() { |
117 | 0 | return this.namespace; |
118 | |
} |
119 | |
|
120 | |
public String getLabel() { |
121 | 0 | return this.label; |
122 | |
} |
123 | |
|
124 | |
public String getDescription() { |
125 | 0 | return description; |
126 | |
} |
127 | |
|
128 | |
public boolean isActive() { |
129 | 0 | return this.active; |
130 | |
} |
131 | |
|
132 | |
public String getComponentName() { |
133 | 0 | return this.componentName; |
134 | |
} |
135 | |
|
136 | |
@Override |
137 | |
public Long getVersionNumber() { |
138 | 0 | return versionNumber; |
139 | |
} |
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | 0 | public static class Builder implements KrmsAttributeDefinitionContract, ModelBuilder, Serializable { |
145 | |
private static final long serialVersionUID = -2110564370088779631L; |
146 | |
|
147 | |
private String id; |
148 | |
private String name; |
149 | |
private String namespace; |
150 | |
private String label; |
151 | |
private String description; |
152 | |
private boolean active; |
153 | |
private String componentName; |
154 | |
private Long versionNumber; |
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | 0 | private Builder(String id, String name, String namespace) { |
160 | 0 | setId(id); |
161 | 0 | setName(name); |
162 | 0 | setNamespace(namespace); |
163 | 0 | setActive(true); |
164 | 0 | } |
165 | |
|
166 | |
public Builder label(String label){ |
167 | 0 | setLabel(label); |
168 | 0 | return this; |
169 | |
} |
170 | |
public Builder componentName(String componentName){ |
171 | 0 | setComponentName(componentName); |
172 | 0 | return this; |
173 | |
} |
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
|
180 | |
|
181 | |
|
182 | |
|
183 | |
public static Builder create(String id, String name, String namespace) { |
184 | 0 | return new Builder(id, name, namespace); |
185 | |
} |
186 | |
|
187 | |
|
188 | |
|
189 | |
|
190 | |
|
191 | |
|
192 | |
|
193 | |
public static Builder create(KrmsAttributeDefinitionContract contract) { |
194 | 0 | if (contract == null) { |
195 | 0 | throw new IllegalArgumentException("contract is null"); |
196 | |
} |
197 | 0 | Builder builder = new Builder(contract.getId(), contract.getName(), contract.getNamespace()); |
198 | 0 | builder.setActive(contract.isActive()); |
199 | 0 | builder.setLabel(contract.getLabel()); |
200 | 0 | builder.setDescription(contract.getDescription()); |
201 | 0 | builder.setComponentName(contract.getComponentName()); |
202 | 0 | builder.setVersionNumber(contract.getVersionNumber()); |
203 | 0 | return builder; |
204 | |
} |
205 | |
|
206 | |
|
207 | |
|
208 | |
|
209 | |
|
210 | |
|
211 | |
|
212 | |
public void setId(String id) { |
213 | 0 | if (null != id && StringUtils.isBlank(id)) { |
214 | 0 | throw new IllegalArgumentException("id must be null or non-blank"); |
215 | |
} |
216 | 0 | this.id = id; |
217 | 0 | } |
218 | |
|
219 | |
public void setName(String name) { |
220 | 0 | if (StringUtils.isBlank(name)) { |
221 | 0 | throw new IllegalArgumentException("name is blank"); |
222 | |
} |
223 | 0 | this.name = name; |
224 | 0 | } |
225 | |
|
226 | |
public void setNamespace(String namespace) { |
227 | 0 | if (StringUtils.isBlank(namespace)) { |
228 | 0 | throw new IllegalArgumentException("namespace is blank"); |
229 | |
} |
230 | 0 | this.namespace = namespace; |
231 | 0 | } |
232 | |
|
233 | |
public void setLabel(String label) { |
234 | 0 | this.label = label; |
235 | 0 | } |
236 | |
|
237 | |
public void setDescription(String description) { |
238 | 0 | this.description = description; |
239 | 0 | } |
240 | |
|
241 | |
|
242 | |
public void setComponentName(String componentName) { |
243 | 0 | this.componentName = componentName; |
244 | 0 | } |
245 | |
|
246 | |
public void setActive(boolean active) { |
247 | 0 | this.active = active; |
248 | 0 | } |
249 | |
|
250 | |
public void setVersionNumber(Long versionNumber){ |
251 | 0 | this.versionNumber = versionNumber; |
252 | 0 | } |
253 | |
|
254 | |
@Override |
255 | |
public String getId() { |
256 | 0 | return id; |
257 | |
} |
258 | |
|
259 | |
@Override |
260 | |
public String getName() { |
261 | 0 | return name; |
262 | |
} |
263 | |
|
264 | |
@Override |
265 | |
public String getNamespace() { |
266 | 0 | return namespace; |
267 | |
} |
268 | |
|
269 | |
@Override |
270 | |
public String getComponentName() { |
271 | 0 | return componentName; |
272 | |
} |
273 | |
|
274 | |
@Override |
275 | |
public String getLabel() { |
276 | 0 | return label; |
277 | |
} |
278 | |
|
279 | |
@Override |
280 | |
public String getDescription() { |
281 | 0 | return description; |
282 | |
} |
283 | |
|
284 | |
@Override |
285 | |
public boolean isActive() { |
286 | 0 | return active; |
287 | |
} |
288 | |
|
289 | |
@Override |
290 | |
public Long getVersionNumber() { |
291 | 0 | return versionNumber; |
292 | |
} |
293 | |
|
294 | |
|
295 | |
|
296 | |
|
297 | |
|
298 | |
|
299 | |
@Override |
300 | |
public KrmsAttributeDefinition build() { |
301 | 0 | return new KrmsAttributeDefinition(this); |
302 | |
} |
303 | |
|
304 | |
} |
305 | |
|
306 | |
|
307 | |
|
308 | |
|
309 | 0 | static class Constants { |
310 | |
final static String ROOT_ELEMENT_NAME = "KrmsAttributeDefinition"; |
311 | |
final static String TYPE_NAME = "KrmsAttributionDefinitionType"; |
312 | |
} |
313 | |
|
314 | |
|
315 | |
|
316 | |
|
317 | |
|
318 | 0 | public static class Elements { |
319 | |
final static String ID = "id"; |
320 | |
final static String NAME = "name"; |
321 | |
final static String NAMESPACE = "namespace"; |
322 | |
final static String LABEL = "label"; |
323 | |
final static String DESCRIPTION = "description"; |
324 | |
final static String COMPONENT_NAME = "componentName"; |
325 | |
final static String ACTIVE = "active"; |
326 | |
} |
327 | |
} |