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 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   * Generated using JVM arguments -DNOT_BLANK=krmsObjectId,krmsDiscriminatorType,referenceObjectId,referenceDiscriminatorType 
35   * Concrete model object implementation, immutable. 
36   * Instances can be (un)marshalled to and from XML.
37   * 
38   * @see ReferenceObjectBindingContract
39   * 
40   * @author Kuali Rice Team (rice.collab@kuali.org)
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       * Private constructor used only by JAXB. This constructor should never be called.
86       * It is only present for use during JAXB unmarshalling.
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      * Constructs an object from the given builder.  This constructor is private and should only ever be invoked from the builder.
103      * 
104      * @param builder the Builder from which to construct the object.
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      * A builder which can be used to construct {@link ReferenceObjectBinding} instances.  Enforces the constraints of the {@link ReferenceObjectBindingContract}.
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             // TODO modify this constructor as needed to pass any required values and invoke the appropriate 'setter' methods
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             // TODO modify as needed to pass any required values and add them to the signature of the 'create' method
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             // TODO if create() is modified to accept required parameters, this will need to be modified
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          * Builds an instance of a ReferenceObjectBinding based on the current state of the builder.
212          * 
213          * @return the fully-constructed ReferenceObjectBinding.
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          * Sets the value of active on this builder to the given value.
267          * 
268          * @param active the active value to set.
269          * 
270          */
271         public void setActive(boolean active) {
272             this.active = active;
273         }
274 
275         /**
276          * Sets the value of collectionName on this builder to the given value.
277          * 
278          * @param collectionName the collectionName value to set.
279          * 
280          */
281         public void setCollectionName(String collectionName) {
282             // TODO add validation of input value if required and throw IllegalArgumentException if needed
283             this.collectionName = collectionName;
284         }
285 
286         /**
287          * Sets the value of id on this builder to the given value.
288          * 
289          * @param id the id value to set., may be null, representing the Object has not been persisted, but must not be blank.
290          * @throws IllegalArgumentException if the id is blank
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          * Sets the value of krmsDiscriminatorType on this builder to the given value.
302          * 
303          * @param krmsDiscriminatorType the krmsDiscriminatorType value to set., must not be null or blank
304          * @throws IllegalArgumentException if the krmsDiscriminatorType is null or blank
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          * Sets the value of krmsObjectId on this builder to the given value.
316          * 
317          * @param krmsObjectId the krmsObjectId value to set., must not be null or blank
318          * @throws IllegalArgumentException if the krmsObjectId is null or blank
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          * Sets the value of namespace on this builder to the given value.
330          * 
331          * @param namespace the namespace value to set., must not be null or blank
332          * @throws IllegalArgumentException if the namespace is null or blank
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          * Sets the value of referenceDiscriminatorType on this builder to the given value.
344          * 
345          * @param referenceDiscriminatorType the referenceDiscriminatorType value to set., must not be null or blank
346          * @throws IllegalArgumentException if the referenceDiscriminatorType is null or blank
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          * Sets the value of referenceObjectId on this builder to the given value.
358          * 
359          * @param referenceObjectId the referenceObjectId value to set., must not be null or blank
360          * @throws IllegalArgumentException if the referenceObjectId is null or blank
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          * Sets the value of versionNumber on this builder to the given value.
372          * 
373          * @param versionNumber the versionNumber value to set.
374          * 
375          */
376         public void setVersionNumber(Long versionNumber) {
377             this.versionNumber = versionNumber;
378         }
379 
380     }
381 
382 
383     /**
384      * Defines some internal constants used on this class.
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      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
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 }