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 | 0 | 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 | 0 | @SuppressWarnings("unused") |
80 | |
@XmlAnyElement |
81 | |
private final Collection<Element> _futureElements = null; |
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | 0 | private FunctionParameterDefinition() { |
87 | 0 | this.id = null; |
88 | 0 | this.name = null; |
89 | 0 | this.description = null; |
90 | 0 | this.parameterType = null; |
91 | 0 | this.functionId = null; |
92 | 0 | this.sequenceNumber = null; |
93 | 0 | this.versionNumber = null; |
94 | 0 | } |
95 | |
|
96 | 0 | private FunctionParameterDefinition(Builder builder) { |
97 | 0 | this.id = builder.getId(); |
98 | 0 | this.name = builder.getName(); |
99 | 0 | this.description = builder.getDescription(); |
100 | 0 | this.parameterType = builder.getParameterType(); |
101 | 0 | this.functionId = builder.getFunctionId(); |
102 | 0 | this.sequenceNumber = builder.getSequenceNumber(); |
103 | 0 | this.versionNumber = builder.getVersionNumber(); |
104 | 0 | } |
105 | |
|
106 | |
@Override |
107 | |
public String getId() { |
108 | 0 | return id; |
109 | |
} |
110 | |
|
111 | |
@Override |
112 | |
public String getName() { |
113 | 0 | return name; |
114 | |
} |
115 | |
|
116 | |
@Override |
117 | |
public String getDescription() { |
118 | 0 | return description; |
119 | |
} |
120 | |
|
121 | |
@Override |
122 | |
public String getParameterType() { |
123 | 0 | return parameterType; |
124 | |
} |
125 | |
|
126 | |
@Override |
127 | |
public String getFunctionId() { |
128 | 0 | return functionId; |
129 | |
} |
130 | |
|
131 | |
@Override |
132 | |
public Long getVersionNumber() { |
133 | 0 | return versionNumber; |
134 | |
} |
135 | |
|
136 | |
@Override |
137 | |
public Integer getSequenceNumber() { |
138 | 0 | return sequenceNumber; |
139 | |
} |
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
|
147 | |
|
148 | 0 | 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 | 0 | private Builder(String name, String type, Integer sequenceNumber) { |
161 | 0 | setName(name); |
162 | 0 | setParameterType(type); |
163 | 0 | setSequenceNumber(sequenceNumber); |
164 | 0 | } |
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
|
173 | |
|
174 | |
|
175 | |
|
176 | |
|
177 | |
public static Builder create(String name, String type, Integer sequenceNumber) { |
178 | 0 | 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 | 0 | if (contract == null) { |
194 | 0 | throw new IllegalArgumentException("contract was null"); |
195 | |
} |
196 | 0 | Builder builder = create(contract.getName(), contract.getParameterType(), contract.getSequenceNumber()); |
197 | 0 | builder.setId(contract.getId()); |
198 | 0 | builder.setDescription(contract.getDescription()); |
199 | 0 | builder.setParameterType(contract.getParameterType()); |
200 | 0 | builder.setFunctionId(contract.getFunctionId()); |
201 | 0 | builder.setVersionNumber(contract.getVersionNumber()); |
202 | 0 | return builder; |
203 | |
} |
204 | |
|
205 | |
@Override |
206 | |
public FunctionParameterDefinition build() { |
207 | 0 | return new FunctionParameterDefinition(this); |
208 | |
} |
209 | |
|
210 | |
@Override |
211 | |
public String getId() { |
212 | 0 | return this.id; |
213 | |
} |
214 | |
|
215 | |
|
216 | |
|
217 | |
|
218 | |
|
219 | |
|
220 | |
public void setId(String id) { |
221 | 0 | this.id = id; |
222 | 0 | } |
223 | |
|
224 | |
@Override |
225 | |
public String getName() { |
226 | 0 | return this.name; |
227 | |
} |
228 | |
|
229 | |
|
230 | |
|
231 | |
|
232 | |
|
233 | |
|
234 | |
|
235 | |
public void setName(String name) { |
236 | 0 | if (StringUtils.isBlank(name)) { |
237 | 0 | throw new IllegalArgumentException("name was blank"); |
238 | |
} |
239 | 0 | this.name = name; |
240 | 0 | } |
241 | |
|
242 | |
@Override |
243 | |
public String getDescription() { |
244 | 0 | return this.description; |
245 | |
} |
246 | |
|
247 | |
|
248 | |
|
249 | |
|
250 | |
|
251 | |
|
252 | |
public void setDescription(String description) { |
253 | 0 | this.description = description; |
254 | 0 | } |
255 | |
|
256 | |
@Override |
257 | |
public String getParameterType() { |
258 | 0 | return this.parameterType; |
259 | |
} |
260 | |
|
261 | |
|
262 | |
|
263 | |
|
264 | |
|
265 | |
|
266 | |
|
267 | |
|
268 | |
|
269 | |
public void setParameterType(String type) { |
270 | 0 | if (StringUtils.isBlank(type)) { |
271 | 0 | throw new IllegalArgumentException("type was blank"); |
272 | |
} |
273 | 0 | this.parameterType = type; |
274 | 0 | } |
275 | |
|
276 | |
@Override |
277 | |
public String getFunctionId() { |
278 | 0 | return this.functionId; |
279 | |
} |
280 | |
|
281 | |
|
282 | |
|
283 | |
|
284 | |
|
285 | |
|
286 | |
|
287 | |
|
288 | |
public void setFunctionId(String functionId) { |
289 | 0 | if (functionId != null && StringUtils.isBlank(functionId)) { |
290 | 0 | throw new IllegalArgumentException("functionId must be null or non-blank"); |
291 | |
} |
292 | 0 | this.functionId = functionId; |
293 | 0 | } |
294 | |
|
295 | |
@Override |
296 | |
public Integer getSequenceNumber() { |
297 | 0 | return this.sequenceNumber; |
298 | |
} |
299 | |
|
300 | |
|
301 | |
|
302 | |
|
303 | |
|
304 | |
|
305 | |
|
306 | |
|
307 | |
public void setSequenceNumber(Integer sequenceNumber) { |
308 | 0 | this.sequenceNumber = sequenceNumber; |
309 | 0 | } |
310 | |
|
311 | |
@Override |
312 | |
public Long getVersionNumber() { |
313 | 0 | return this.versionNumber; |
314 | |
} |
315 | |
|
316 | |
|
317 | |
|
318 | |
|
319 | |
|
320 | |
|
321 | |
|
322 | |
|
323 | |
|
324 | |
|
325 | |
|
326 | |
public void setVersionNumber(Long versionNumber) { |
327 | 0 | this.versionNumber = versionNumber; |
328 | 0 | } |
329 | |
|
330 | |
} |
331 | |
|
332 | |
|
333 | |
|
334 | |
|
335 | 0 | 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 | 0 | 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 | |
} |