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