View Javadoc

1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * Generated using JVM arguments -DNOT_BLANK=krmsObjectId,krmsDiscriminatorType,referenceObjectId,referenceDiscriminatorType 
33   * Concrete model object implementation, immutable. 
34   * Instances can be (un)marshalled to and from XML.
35   * 
36   * @see ReferenceObjectBindingContract
37   * 
38   * @author Kuali Rice Team (rice.collab@kuali.org)
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       * Private constructor used only by JAXB. This constructor should never be called.
84       * It is only present for use during JAXB unmarshalling.
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      * Constructs an object from the given builder.  This constructor is private and should only ever be invoked from the builder.
101      * 
102      * @param builder the Builder from which to construct the object.
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      * A builder which can be used to construct {@link ReferenceObjectBinding} instances.  Enforces the constraints of the {@link ReferenceObjectBindingContract}.
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             // TODO modify this constructor as needed to pass any required values and invoke the appropriate 'setter' methods
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             // TODO modify as needed to pass any required values and add them to the signature of the 'create' method
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             // TODO if create() is modified to accept required parameters, this will need to be modified
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          * Builds an instance of a ReferenceObjectBinding based on the current state of the builder.
210          * 
211          * @return the fully-constructed ReferenceObjectBinding.
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          * Sets the value of active on this builder to the given value.
265          * 
266          * @param active the active value to set.
267          * 
268          */
269         public void setActive(boolean active) {
270             this.active = active;
271         }
272 
273         /**
274          * Sets the value of collectionName on this builder to the given value.
275          * 
276          * @param collectionName the collectionName value to set.
277          * 
278          */
279         public void setCollectionName(String collectionName) {
280             // TODO add validation of input value if required and throw IllegalArgumentException if needed
281             this.collectionName = collectionName;
282         }
283 
284         /**
285          * Sets the value of id on this builder to the given value.
286          * 
287          * @param id the id value to set., may be null, representing the Object has not been persisted, but must not be blank.
288          * @throws IllegalArgumentException if the id is blank
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          * Sets the value of krmsDiscriminatorType on this builder to the given value.
300          * 
301          * @param krmsDiscriminatorType the krmsDiscriminatorType value to set., must not be null or blank
302          * @throws IllegalArgumentException if the krmsDiscriminatorType is null or blank
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          * Sets the value of krmsObjectId on this builder to the given value.
314          * 
315          * @param krmsObjectId the krmsObjectId value to set., must not be null or blank
316          * @throws IllegalArgumentException if the krmsObjectId is null or blank
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          * Sets the value of namespace on this builder to the given value.
328          * 
329          * @param namespace the namespace value to set., must not be null or blank
330          * @throws IllegalArgumentException if the namespace is null or blank
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          * Sets the value of referenceDiscriminatorType on this builder to the given value.
342          * 
343          * @param referenceDiscriminatorType the referenceDiscriminatorType value to set., must not be null or blank
344          * @throws IllegalArgumentException if the referenceDiscriminatorType is null or blank
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          * Sets the value of referenceObjectId on this builder to the given value.
356          * 
357          * @param referenceObjectId the referenceObjectId value to set., must not be null or blank
358          * @throws IllegalArgumentException if the referenceObjectId is null or blank
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          * Sets the value of versionNumber on this builder to the given value.
370          * 
371          * @param versionNumber the versionNumber value to set.
372          * 
373          */
374         public void setVersionNumber(Long versionNumber) {
375             this.versionNumber = versionNumber;
376         }
377 
378     }
379 
380 
381     /**
382      * Defines some internal constants used on this class.
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      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
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 }