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