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