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