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.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   * Generated using JVM arguments -DNOT_BLANK=name 
35   * Concrete model object implementation, immutable. 
36   * Instances can be (un)marshalled to and from XML.
37   * 
38   * @see NaturalLanguageTemplateAttributeContract
39   * 
40   * @author Kuali Rice Team (rice.collab@kuali.org)
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       * Private constructor used only by JAXB. This constructor should never be called.
77       * It is only present for use during JAXB unmarshalling.
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       * Constructs an object from the given builder.  This constructor is private and should only ever be invoked from the builder.
91       * 
92       * @param builder the Builder from which to construct the object.
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      * A builder which can be used to construct {@link NaturalLanguageTemplateAttribute} instances.  Enforces the constraints of the {@link NaturalLanguageTemplateAttributeContract}.
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             // TODO modify this constructor as needed to pass any required values and invoke the appropriate 'setter' methods
156         }
157 
158         public static Builder create() {
159             // TODO modify as needed to pass any required values and add them to the signature of the 'create' method
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             // TODO if create() is modified to accept required parameters, this will need to be modified
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          * Builds an instance of a NaturalLanguageTemplateAttribute based on the current state of the builder.
182          * 
183          * @return the fully-constructed NaturalLanguageTemplateAttribute.
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          * Sets the value of attributeDefinitionId on this builder to the given value.
226          * 
227          * @param attributeDefinitionId the attributeDefinitionId value to set.
228          * 
229          */
230         public void setAttributeDefinitionId(String attributeDefinitionId) {
231             // TODO add validation of input value if required and throw IllegalArgumentException if needed
232             this.attributeDefinitionId = attributeDefinitionId;
233         }
234 
235         /**
236          * Sets the value of id on this builder to the given value.
237          * 
238          * @param id the id value to set., may be null, representing the Object has not been persisted, but must not be blank.
239          * @throws IllegalArgumentException if the id is blank
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          * Sets the value of naturalLanguageTemplateId on this builder to the given value.
251          * 
252          * @param naturalLanguageTemplateId the naturalLanguageTemplateId value to set.
253          * 
254          */
255         public void setNaturalLanguageTemplateId(String naturalLanguageTemplateId) {
256             // TODO add validation of input value if required and throw IllegalArgumentException if needed
257             this.naturalLanguageTemplateId = naturalLanguageTemplateId;
258         }
259 
260         /**
261          * Sets the value of value on this builder to the given value.
262          * 
263          * @param value the value value to set.
264          * 
265          */
266         public void setValue(String value) {
267             // TODO add validation of input value if required and throw IllegalArgumentException if needed
268             this.value = value;
269         }
270 
271         /**
272          * Sets the value of versionNumber on this builder to the given value.
273          * 
274          * @param versionNumber the versionNumber value to set.
275          * 
276          */
277         public void setVersionNumber(Long versionNumber) {
278             this.versionNumber = versionNumber;
279         }
280 
281     }
282 
283 
284     /**
285      * Defines some internal constants used on this class.
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      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
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 }