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