1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.api.repository.reference;
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 javax.xml.bind.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 = ReferenceObjectBinding.Constants.ROOT_ELEMENT_NAME)
42 @XmlAccessorType(XmlAccessType.NONE)
43 @XmlType(name = ReferenceObjectBinding.Constants.TYPE_NAME, propOrder = {
44 ReferenceObjectBinding.Elements.COLLECTION_NAME,
45 ReferenceObjectBinding.Elements.KRMS_DISCRIMINATOR_TYPE,
46 ReferenceObjectBinding.Elements.KRMS_OBJECT_ID,
47 ReferenceObjectBinding.Elements.NAMESPACE,
48 ReferenceObjectBinding.Elements.REFERENCE_DISCRIMINATOR_TYPE,
49 ReferenceObjectBinding.Elements.REFERENCE_OBJECT_ID,
50 ReferenceObjectBinding.Elements.ID,
51 ReferenceObjectBinding.Elements.ACTIVE,
52 CoreConstants.CommonElements.VERSION_NUMBER,
53 CoreConstants.CommonElements.FUTURE_ELEMENTS
54 })
55 public final class ReferenceObjectBinding
56 extends AbstractDataTransferObject
57 implements ReferenceObjectBindingContract
58 {
59
60 @XmlElement(name = Elements.COLLECTION_NAME, required = false)
61 private final String collectionName;
62 @XmlElement(name = Elements.KRMS_DISCRIMINATOR_TYPE, required = false)
63 private final String krmsDiscriminatorType;
64 @XmlElement(name = Elements.KRMS_OBJECT_ID, required = false)
65 private final String krmsObjectId;
66 @XmlElement(name = Elements.NAMESPACE, required = false)
67 private final String namespace;
68 @XmlElement(name = Elements.REFERENCE_DISCRIMINATOR_TYPE, required = false)
69 private final String referenceDiscriminatorType;
70 @XmlElement(name = Elements.REFERENCE_OBJECT_ID, required = false)
71 private final String referenceObjectId;
72 @XmlElement(name = Elements.ID, required = false)
73 private final String id;
74 @XmlElement(name = Elements.ACTIVE, required = false)
75 private final boolean active;
76 @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
77 private final Long versionNumber;
78 @SuppressWarnings("unused")
79 @XmlAnyElement
80 private final Collection<Element> _futureElements = null;
81
82
83
84
85
86
87 private ReferenceObjectBinding() {
88 this.collectionName = null;
89 this.krmsDiscriminatorType = null;
90 this.krmsObjectId = null;
91 this.namespace = null;
92 this.referenceDiscriminatorType = null;
93 this.referenceObjectId = null;
94 this.id = null;
95 this.active = false;
96 this.versionNumber = null;
97 }
98
99
100
101
102
103
104
105 private ReferenceObjectBinding(Builder builder) {
106 this.collectionName = builder.getCollectionName();
107 this.krmsDiscriminatorType = builder.getKrmsDiscriminatorType();
108 this.krmsObjectId = builder.getKrmsObjectId();
109 this.namespace = builder.getNamespace();
110 this.referenceDiscriminatorType = builder.getReferenceDiscriminatorType();
111 this.referenceObjectId = builder.getReferenceObjectId();
112 this.id = builder.getId();
113 this.active = builder.isActive();
114 this.versionNumber = builder.getVersionNumber();
115 }
116
117 @Override
118 public String getCollectionName() {
119 return this.collectionName;
120 }
121
122 @Override
123 public String getKrmsDiscriminatorType() {
124 return this.krmsDiscriminatorType;
125 }
126
127 @Override
128 public String getKrmsObjectId() {
129 return this.krmsObjectId;
130 }
131
132 @Override
133 public String getNamespace() {
134 return this.namespace;
135 }
136
137 @Override
138 public String getReferenceDiscriminatorType() {
139 return this.referenceDiscriminatorType;
140 }
141
142 @Override
143 public String getReferenceObjectId() {
144 return this.referenceObjectId;
145 }
146
147 @Override
148 public String getId() {
149 return this.id;
150 }
151
152 @Override
153 public boolean isActive() {
154 return this.active;
155 }
156
157 @Override
158 public Long getVersionNumber() {
159 return this.versionNumber;
160 }
161
162
163
164
165
166
167 public final static class Builder
168 implements Serializable, ModelBuilder, ReferenceObjectBindingContract
169 {
170
171 private String collectionName;
172 private String krmsDiscriminatorType;
173 private String krmsObjectId;
174 private String namespace;
175 private String referenceDiscriminatorType;
176 private String referenceObjectId;
177 private String id;
178 private boolean active;
179 private Long versionNumber;
180
181 private Builder(String krmsDiscriminatorType, String krmsObjectId, String namespace, String referenceDiscriminatorType, String referenceObjectId) {
182
183 setKrmsDiscriminatorType(krmsDiscriminatorType);
184 setKrmsObjectId(krmsObjectId);
185 setNamespace(namespace);
186 setReferenceDiscriminatorType(referenceDiscriminatorType);
187 setReferenceObjectId(referenceObjectId);
188 }
189
190 public static Builder create(String krmsDiscriminatorType, String krmsObjectId, String namespace, String referenceDiscriminatorType, String referenceObjectId) {
191
192 return new Builder(krmsDiscriminatorType, krmsObjectId, namespace, referenceDiscriminatorType, referenceObjectId);
193 }
194
195 public static Builder create(ReferenceObjectBindingContract contract) {
196 if (contract == null) {
197 throw new IllegalArgumentException("contract was null");
198 }
199
200 Builder builder = create(contract.getKrmsDiscriminatorType(), contract.getKrmsObjectId(), contract.getNamespace(), contract.getReferenceDiscriminatorType(), contract.getReferenceObjectId());
201 builder.setId(contract.getId());
202 builder.setActive(contract.isActive());
203 builder.setCollectionName(contract.getCollectionName());
204 builder.setVersionNumber(contract.getVersionNumber());
205 return builder;
206 }
207
208
209
210
211
212
213
214 public ReferenceObjectBinding build() {
215 return new ReferenceObjectBinding(this);
216 }
217
218 @Override
219 public boolean isActive() {
220 return this.active;
221 }
222
223 @Override
224 public String getCollectionName() {
225 return this.collectionName;
226 }
227
228 @Override
229 public String getId() {
230 return this.id;
231 }
232
233 @Override
234 public String getKrmsDiscriminatorType() {
235 return this.krmsDiscriminatorType;
236 }
237
238 @Override
239 public String getKrmsObjectId() {
240 return this.krmsObjectId;
241 }
242
243 @Override
244 public String getNamespace() {
245 return this.namespace;
246 }
247
248 @Override
249 public String getReferenceDiscriminatorType() {
250 return this.referenceDiscriminatorType;
251 }
252
253 @Override
254 public String getReferenceObjectId() {
255 return this.referenceObjectId;
256 }
257
258 @Override
259 public Long getVersionNumber() {
260 return this.versionNumber;
261 }
262
263
264
265
266
267
268
269 public void setActive(boolean active) {
270 this.active = active;
271 }
272
273
274
275
276
277
278
279 public void setCollectionName(String collectionName) {
280
281 this.collectionName = collectionName;
282 }
283
284
285
286
287
288
289
290
291 public void setId(String id) {
292 if (id != null && org.apache.commons.lang.StringUtils.isBlank(id)) {
293 throw new IllegalArgumentException("id is blank");
294 }
295 this.id = id;
296 }
297
298
299
300
301
302
303
304
305 public void setKrmsDiscriminatorType(String krmsDiscriminatorType) {
306 if (org.apache.commons.lang.StringUtils.isBlank(krmsDiscriminatorType)) {
307 throw new IllegalArgumentException("krmsDiscriminatorType is null or blank");
308 }
309 this.krmsDiscriminatorType = krmsDiscriminatorType;
310 }
311
312
313
314
315
316
317
318
319 public void setKrmsObjectId(String krmsObjectId) {
320 if (org.apache.commons.lang.StringUtils.isBlank(krmsObjectId)) {
321 throw new IllegalArgumentException("krmsObjectId is null or blank");
322 }
323 this.krmsObjectId = krmsObjectId;
324 }
325
326
327
328
329
330
331
332
333 public void setNamespace(String namespace) {
334 if (org.apache.commons.lang.StringUtils.isBlank(namespace)) {
335 throw new IllegalArgumentException("namespace is null or blank");
336 }
337 this.namespace = namespace;
338 }
339
340
341
342
343
344
345
346
347 public void setReferenceDiscriminatorType(String referenceDiscriminatorType) {
348 if (org.apache.commons.lang.StringUtils.isBlank(referenceDiscriminatorType)) {
349 throw new IllegalArgumentException("referenceDiscriminatorType is null or blank");
350 }
351 this.referenceDiscriminatorType = referenceDiscriminatorType;
352 }
353
354
355
356
357
358
359
360
361 public void setReferenceObjectId(String referenceObjectId) {
362 if (org.apache.commons.lang.StringUtils.isBlank(referenceObjectId)) {
363 throw new IllegalArgumentException("referenceObjectId is null or blank");
364 }
365 this.referenceObjectId = referenceObjectId;
366 }
367
368
369
370
371
372
373
374 public void setVersionNumber(Long versionNumber) {
375 this.versionNumber = versionNumber;
376 }
377
378 }
379
380
381
382
383
384
385 static class Constants {
386
387 final static String ROOT_ELEMENT_NAME = "referenceObjectBinding";
388 final static String TYPE_NAME = "ReferenceObjectBindingType";
389
390 }
391
392
393
394
395
396
397 static class Elements {
398
399 final static String COLLECTION_NAME = "collectionName";
400 final static String KRMS_DISCRIMINATOR_TYPE = "krmsDiscriminatorType";
401 final static String KRMS_OBJECT_ID = "krmsObjectId";
402 final static String NAMESPACE = "namespace";
403 final static String REFERENCE_DISCRIMINATOR_TYPE = "referenceDiscriminatorType";
404 final static String REFERENCE_OBJECT_ID = "referenceObjectId";
405 final static String ID = "id";
406 final static String ACTIVE = "active";
407
408 }
409
410 }