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