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
97
98
99
100
101
102 private FunctionParameterDefinition(Builder builder) {
103 this.id = builder.getId();
104 this.name = builder.getName();
105 this.description = builder.getDescription();
106 this.parameterType = builder.getParameterType();
107 this.functionId = builder.getFunctionId();
108 this.sequenceNumber = builder.getSequenceNumber();
109 this.versionNumber = builder.getVersionNumber();
110 }
111
112 @Override
113 public String getId() {
114 return id;
115 }
116
117 @Override
118 public String getName() {
119 return name;
120 }
121
122 @Override
123 public String getDescription() {
124 return description;
125 }
126
127 @Override
128 public String getParameterType() {
129 return parameterType;
130 }
131
132 @Override
133 public String getFunctionId() {
134 return functionId;
135 }
136
137 @Override
138 public Long getVersionNumber() {
139 return versionNumber;
140 }
141
142 @Override
143 public Integer getSequenceNumber() {
144 return sequenceNumber;
145 }
146
147
148
149
150
151
152
153
154 public static final class Builder implements FunctionParameterDefinitionContract, ModelBuilder, Serializable {
155
156 private static final long serialVersionUID = -4470376239998290245L;
157
158 private String id;
159 private String name;
160 private String description;
161 private String functionId;
162 private String parameterType;
163 private Integer sequenceNumber;
164 private Long versionNumber;
165
166
167
168
169
170
171
172 private Builder(String name, String type, Integer sequenceNumber) {
173 setName(name);
174 setParameterType(type);
175 setSequenceNumber(sequenceNumber);
176 }
177
178
179
180
181
182
183
184
185
186
187
188
189 public static Builder create(String name, String type, Integer sequenceNumber) {
190 return new Builder(name, type, sequenceNumber);
191 }
192
193
194
195
196
197
198
199
200
201
202
203
204 public static Builder create(FunctionParameterDefinitionContract contract) {
205 if (contract == null) {
206 throw new IllegalArgumentException("contract was null");
207 }
208 Builder builder = create(contract.getName(), contract.getParameterType(), contract.getSequenceNumber());
209 builder.setId(contract.getId());
210 builder.setDescription(contract.getDescription());
211 builder.setParameterType(contract.getParameterType());
212 builder.setFunctionId(contract.getFunctionId());
213 builder.setVersionNumber(contract.getVersionNumber());
214 return builder;
215 }
216
217 @Override
218 public FunctionParameterDefinition build() {
219 return new FunctionParameterDefinition(this);
220 }
221
222 @Override
223 public String getId() {
224 return this.id;
225 }
226
227
228
229
230
231
232 public void setId(String id) {
233 this.id = id;
234 }
235
236 @Override
237 public String getName() {
238 return this.name;
239 }
240
241
242
243
244
245
246
247 public void setName(String name) {
248 if (StringUtils.isBlank(name)) {
249 throw new IllegalArgumentException("name was blank");
250 }
251 this.name = name;
252 }
253
254 @Override
255 public String getDescription() {
256 return this.description;
257 }
258
259
260
261
262
263
264 public void setDescription(String description) {
265 this.description = description;
266 }
267
268 @Override
269 public String getParameterType() {
270 return this.parameterType;
271 }
272
273
274
275
276
277
278
279
280
281 public void setParameterType(String type) {
282 if (StringUtils.isBlank(type)) {
283 throw new IllegalArgumentException("type was blank");
284 }
285 this.parameterType = type;
286 }
287
288 @Override
289 public String getFunctionId() {
290 return this.functionId;
291 }
292
293
294
295
296
297
298
299
300 public void setFunctionId(String functionId) {
301 if (functionId != null && StringUtils.isBlank(functionId)) {
302 throw new IllegalArgumentException("functionId must be null or non-blank");
303 }
304 this.functionId = functionId;
305 }
306
307 @Override
308 public Integer getSequenceNumber() {
309 return this.sequenceNumber;
310 }
311
312
313
314
315
316
317
318
319 public void setSequenceNumber(Integer sequenceNumber) {
320 this.sequenceNumber = sequenceNumber;
321 }
322
323 @Override
324 public Long getVersionNumber() {
325 return this.versionNumber;
326 }
327
328
329
330
331
332
333
334
335
336
337
338 public void setVersionNumber(Long versionNumber) {
339 this.versionNumber = versionNumber;
340 }
341
342 }
343
344
345
346
347 static class Constants {
348 final static String ROOT_ELEMENT_NAME = "functionParameter";
349 final static String TYPE_NAME = "FunctionParameterType";
350 }
351
352
353
354
355
356 static class Elements {
357 final static String ID = "id";
358 final static String NAME = "name";
359 final static String DESCRIPTION = "description";
360 final static String PARAMETER_TYPE = "parameterType";
361 final static String TYPE = "type";
362 final static String FUNCTION_ID = "functionId";
363 final static String SEQUENCE = "sequenceNumber";
364 }
365
366 }