1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.api.repository.function;
17
18 import java.io.Serializable;
19 import java.util.Collection;
20
21 import javax.xml.bind.annotation.XmlAccessType;
22 import javax.xml.bind.annotation.XmlAccessorType;
23 import javax.xml.bind.annotation.XmlAnyElement;
24 import javax.xml.bind.annotation.XmlElement;
25 import javax.xml.bind.annotation.XmlRootElement;
26 import javax.xml.bind.annotation.XmlType;
27
28 import org.apache.commons.lang.StringUtils;
29 import org.kuali.rice.core.api.CoreConstants;
30 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
31 import org.kuali.rice.core.api.mo.ModelBuilder;
32 import org.w3c.dom.Element;
33
34
35
36
37
38
39
40
41
42 @XmlRootElement(name = FunctionParameterDefinition.Constants.ROOT_ELEMENT_NAME)
43 @XmlAccessorType(XmlAccessType.NONE)
44 @XmlType(name = FunctionParameterDefinition.Constants.TYPE_NAME, propOrder = {
45 FunctionParameterDefinition.Elements.ID,
46 FunctionParameterDefinition.Elements.NAME,
47 FunctionParameterDefinition.Elements.DESCRIPTION,
48 FunctionParameterDefinition.Elements.PARAMETER_TYPE,
49 FunctionParameterDefinition.Elements.SEQUENCE,
50 FunctionParameterDefinition.Elements.FUNCTION_ID,
51 CoreConstants.CommonElements.VERSION_NUMBER,
52 CoreConstants.CommonElements.FUTURE_ELEMENTS
53 })
54 public class FunctionParameterDefinition extends AbstractDataTransferObject implements FunctionParameterDefinitionContract {
55
56 private static final long serialVersionUID = 1391030685309770560L;
57
58 @XmlElement(name = Elements.ID, required = false)
59 private final String id;
60
61 @XmlElement(name = Elements.NAME, required = true)
62 private final String name;
63
64 @XmlElement(name = Elements.DESCRIPTION, required = false)
65 private final String description;
66
67 @XmlElement(name = Elements.TYPE, required = true)
68 private final String parameterType;
69
70 @XmlElement(name = Elements.FUNCTION_ID, required = true)
71 private final String functionId;
72
73 @XmlElement(name = Elements.SEQUENCE, required=true)
74 private Integer sequenceNumber;
75
76 @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
77 private final Long versionNumber;
78
79 @SuppressWarnings("unused")
80 @XmlAnyElement
81 private final Collection<Element> _futureElements = null;
82
83
84
85
86 private FunctionParameterDefinition() {
87 this.id = null;
88 this.name = null;
89 this.description = null;
90 this.parameterType = null;
91 this.functionId = null;
92 this.sequenceNumber = null;
93 this.versionNumber = null;
94 }
95
96 private FunctionParameterDefinition(Builder builder) {
97 this.id = builder.getId();
98 this.name = builder.getName();
99 this.description = builder.getDescription();
100 this.parameterType = builder.getParameterType();
101 this.functionId = builder.getFunctionId();
102 this.sequenceNumber = builder.getSequenceNumber();
103 this.versionNumber = builder.getVersionNumber();
104 }
105
106 @Override
107 public String getId() {
108 return id;
109 }
110
111 @Override
112 public String getName() {
113 return name;
114 }
115
116 @Override
117 public String getDescription() {
118 return description;
119 }
120
121 @Override
122 public String getParameterType() {
123 return parameterType;
124 }
125
126 @Override
127 public String getFunctionId() {
128 return functionId;
129 }
130
131 @Override
132 public Long getVersionNumber() {
133 return versionNumber;
134 }
135
136 @Override
137 public Integer getSequenceNumber() {
138 return sequenceNumber;
139 }
140
141
142
143
144
145
146
147
148 public static final class Builder implements FunctionParameterDefinitionContract, ModelBuilder, Serializable {
149
150 private static final long serialVersionUID = -4470376239998290245L;
151
152 private String id;
153 private String name;
154 private String description;
155 private String functionId;
156 private String parameterType;
157 private Integer sequenceNumber;
158 private Long versionNumber;
159
160 private Builder(String name, String type, Integer sequenceNumber) {
161 setName(name);
162 setParameterType(type);
163 setSequenceNumber(sequenceNumber);
164 }
165
166
167
168
169
170
171
172
173
174
175
176
177 public static Builder create(String name, String type, Integer sequenceNumber) {
178 return new Builder(name, type, sequenceNumber);
179 }
180
181
182
183
184
185
186
187
188
189
190
191
192 public static Builder create(FunctionParameterDefinitionContract contract) {
193 if (contract == null) {
194 throw new IllegalArgumentException("contract was null");
195 }
196 Builder builder = create(contract.getName(), contract.getParameterType(), contract.getSequenceNumber());
197 builder.setId(contract.getId());
198 builder.setDescription(contract.getDescription());
199 builder.setParameterType(contract.getParameterType());
200 builder.setFunctionId(contract.getFunctionId());
201 builder.setVersionNumber(contract.getVersionNumber());
202 return builder;
203 }
204
205 @Override
206 public FunctionParameterDefinition build() {
207 return new FunctionParameterDefinition(this);
208 }
209
210 @Override
211 public String getId() {
212 return this.id;
213 }
214
215
216
217
218
219
220 public void setId(String id) {
221 this.id = id;
222 }
223
224 @Override
225 public String getName() {
226 return this.name;
227 }
228
229
230
231
232
233
234
235 public void setName(String name) {
236 if (StringUtils.isBlank(name)) {
237 throw new IllegalArgumentException("name was blank");
238 }
239 this.name = name;
240 }
241
242 @Override
243 public String getDescription() {
244 return this.description;
245 }
246
247
248
249
250
251
252 public void setDescription(String description) {
253 this.description = description;
254 }
255
256 @Override
257 public String getParameterType() {
258 return this.parameterType;
259 }
260
261
262
263
264
265
266
267
268
269 public void setParameterType(String type) {
270 if (StringUtils.isBlank(type)) {
271 throw new IllegalArgumentException("type was blank");
272 }
273 this.parameterType = type;
274 }
275
276 @Override
277 public String getFunctionId() {
278 return this.functionId;
279 }
280
281
282
283
284
285
286
287
288 public void setFunctionId(String functionId) {
289 if (functionId != null && StringUtils.isBlank(functionId)) {
290 throw new IllegalArgumentException("functionId must be null or non-blank");
291 }
292 this.functionId = functionId;
293 }
294
295 @Override
296 public Integer getSequenceNumber() {
297 return this.sequenceNumber;
298 }
299
300
301
302
303
304
305
306
307 public void setSequenceNumber(Integer sequenceNumber) {
308 this.sequenceNumber = sequenceNumber;
309 }
310
311 @Override
312 public Long getVersionNumber() {
313 return this.versionNumber;
314 }
315
316
317
318
319
320
321
322
323
324
325
326 public void setVersionNumber(Long versionNumber) {
327 this.versionNumber = versionNumber;
328 }
329
330 }
331
332
333
334
335 static class Constants {
336 final static String ROOT_ELEMENT_NAME = "functionParameter";
337 final static String TYPE_NAME = "FunctionParameterType";
338 }
339
340
341
342
343
344 static class Elements {
345 final static String ID = "id";
346 final static String NAME = "name";
347 final static String DESCRIPTION = "description";
348 final static String PARAMETER_TYPE = "parameterType";
349 final static String TYPE = "type";
350 final static String FUNCTION_ID = "functionId";
351 final static String SEQUENCE = "sequenceNumber";
352 }
353
354 }