001 /**
002 * Copyright 2005-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.krms.api.repository.language;
017
018 import org.kuali.rice.core.api.CoreConstants;
019 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
020 import org.kuali.rice.core.api.mo.ModelBuilder;
021 import org.kuali.rice.krms.api.repository.type.KrmsAttributeDefinition;
022 import org.kuali.rice.krms.api.repository.type.KrmsAttributeDefinitionContract;
023 import org.w3c.dom.Element;
024 import javax.xml.bind.annotation.XmlAccessType;
025 import javax.xml.bind.annotation.XmlAccessorType;
026 import javax.xml.bind.annotation.XmlAnyElement;
027 import javax.xml.bind.annotation.XmlElement;
028 import javax.xml.bind.annotation.XmlRootElement;
029 import javax.xml.bind.annotation.XmlType;
030 import java.io.Serializable;
031 import java.util.Collection;
032
033 /**
034 * Generated using JVM arguments -DNOT_BLANK=name
035 * Concrete model object implementation, immutable.
036 * Instances can be (un)marshalled to and from XML.
037 *
038 * @see NaturalLanguageTemplateAttributeContract
039 *
040 * @author Kuali Rice Team (rice.collab@kuali.org)
041 *
042 */
043 @XmlRootElement(name = NaturalLanguageTemplateAttribute.Constants.ROOT_ELEMENT_NAME)
044 @XmlAccessorType(XmlAccessType.NONE)
045 @XmlType(name = NaturalLanguageTemplateAttribute.Constants.TYPE_NAME, propOrder = {
046 NaturalLanguageTemplateAttribute.Elements.NATURAL_LANGUAGE_TEMPLATE_ID,
047 CoreConstants.CommonElements.VERSION_NUMBER,
048 NaturalLanguageTemplateAttribute.Elements.VALUE,
049 NaturalLanguageTemplateAttribute.Elements.ATTRIBUTE_DEFINITION_ID,
050 NaturalLanguageTemplateAttribute.Elements.ATTRIBUTE_DEFINITION,
051 NaturalLanguageTemplateAttribute.Elements.ID,
052 CoreConstants.CommonElements.FUTURE_ELEMENTS
053 })
054 public final class NaturalLanguageTemplateAttribute
055 extends AbstractDataTransferObject
056 implements NaturalLanguageTemplateAttributeContract
057 {
058
059 @XmlElement(name = Elements.NATURAL_LANGUAGE_TEMPLATE_ID, required = false)
060 private final String naturalLanguageTemplateId;
061 @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
062 private final Long versionNumber;
063 @XmlElement(name = Elements.VALUE, required = false)
064 private final String value;
065 @XmlElement(name = Elements.ATTRIBUTE_DEFINITION_ID, required = false)
066 private final String attributeDefinitionId;
067 @XmlElement(name = Elements.ATTRIBUTE_DEFINITION, required = false)
068 private final KrmsAttributeDefinition attributeDefinition;
069 @XmlElement(name = Elements.ID, required = false)
070 private final String id;
071 @SuppressWarnings("unused")
072 @XmlAnyElement
073 private final Collection<Element> _futureElements = null;
074
075 /**
076 * Private constructor used only by JAXB. This constructor should never be called.
077 * It is only present for use during JAXB unmarshalling.
078 *
079 */
080 private NaturalLanguageTemplateAttribute() {
081 this.naturalLanguageTemplateId = null;
082 this.versionNumber = null;
083 this.value = null;
084 this.attributeDefinitionId = null;
085 this.attributeDefinition = null;
086 this.id = null;
087 }
088
089 /**
090 * Constructs an object from the given builder. This constructor is private and should only ever be invoked from the builder.
091 *
092 * @param builder the Builder from which to construct the object.
093 *
094 */
095 private NaturalLanguageTemplateAttribute(Builder builder) {
096 this.naturalLanguageTemplateId = builder.getNaturalLanguageTemplateId();
097 this.versionNumber = builder.getVersionNumber();
098 this.value = builder.getValue();
099 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 }