1
2
3
4
5
6 package fr.ifremer.quadrige2.core.dao.system.rule;
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 import java.io.Serializable;
30 import java.sql.Timestamp;
31 import java.util.Collection;
32 import java.util.Date;
33 import java.util.HashSet;
34
35
36
37
38
39 public abstract class Function
40 implements Serializable, Comparable<Function>
41 {
42
43
44
45 private static final long serialVersionUID = -6054206330509848492L;
46
47
48 private Integer functionId;
49
50
51
52
53
54 public Integer getFunctionId()
55 {
56 return this.functionId;
57 }
58
59
60
61
62
63 public void setFunctionId(Integer functionIdIn)
64 {
65 this.functionId = functionIdIn;
66 }
67
68 private String functionNm;
69
70
71
72
73
74 public String getFunctionNm()
75 {
76 return this.functionNm;
77 }
78
79
80
81
82
83 public void setFunctionNm(String functionNmIn)
84 {
85 this.functionNm = functionNmIn;
86 }
87
88 private String functionJavaFunctionClass;
89
90
91
92
93
94 public String getFunctionJavaFunctionClass()
95 {
96 return this.functionJavaFunctionClass;
97 }
98
99
100
101
102
103 public void setFunctionJavaFunctionClass(String functionJavaFunctionClassIn)
104 {
105 this.functionJavaFunctionClass = functionJavaFunctionClassIn;
106 }
107
108 private Date functionCreationDt;
109
110
111
112
113
114 public Date getFunctionCreationDt()
115 {
116 return this.functionCreationDt;
117 }
118
119
120
121
122
123 public void setFunctionCreationDt(Date functionCreationDtIn)
124 {
125 this.functionCreationDt = functionCreationDtIn;
126 }
127
128 private Timestamp updateDt;
129
130
131
132
133
134 public Timestamp getUpdateDt()
135 {
136 return this.updateDt;
137 }
138
139
140
141
142
143 public void setUpdateDt(Timestamp updateDtIn)
144 {
145 this.updateDt = updateDtIn;
146 }
147
148
149 private Collection<FunctionParameter> functionParameters = new HashSet<FunctionParameter>();
150
151
152
153
154
155 public Collection<FunctionParameter> getFunctionParameters()
156 {
157 return this.functionParameters;
158 }
159
160
161
162
163
164 public void setFunctionParameters(Collection<FunctionParameter> functionParametersIn)
165 {
166 this.functionParameters = functionParametersIn;
167 }
168
169
170
171
172
173
174
175 public boolean addFunctionParameters(FunctionParameter elementToAdd)
176 {
177 return this.functionParameters.add(elementToAdd);
178 }
179
180
181
182
183
184
185
186 public boolean removeFunctionParameters(FunctionParameter elementToRemove)
187 {
188 return this.functionParameters.remove(elementToRemove);
189 }
190
191
192
193
194
195 @Override
196 public boolean equals(Object object)
197 {
198 if (this == object)
199 {
200 return true;
201 }
202 if (!(object instanceof Function))
203 {
204 return false;
205 }
206 final Function that = (Function)object;
207 if (this.functionId == null || that.getFunctionId() == null || !this.functionId.equals(that.getFunctionId()))
208 {
209 return false;
210 }
211 return true;
212 }
213
214
215
216
217 @Override
218 public int hashCode()
219 {
220 int hashCode = 0;
221 hashCode = 29 * hashCode + (this.functionId == null ? 0 : this.functionId.hashCode());
222
223 return hashCode;
224 }
225
226
227
228
229 public static final class Factory
230 {
231
232
233
234
235 public static Function newInstance()
236 {
237 return new FunctionImpl();
238 }
239
240
241
242
243
244
245
246
247
248
249 public static Function newInstance(String functionNm, String functionJavaFunctionClass, Date functionCreationDt, Timestamp updateDt)
250 {
251 final Function entity = new FunctionImpl();
252 entity.setFunctionNm(functionNm);
253 entity.setFunctionJavaFunctionClass(functionJavaFunctionClass);
254 entity.setFunctionCreationDt(functionCreationDt);
255 entity.setUpdateDt(updateDt);
256 return entity;
257 }
258
259
260
261
262
263
264
265
266
267
268
269 public static Function newInstance(String functionNm, String functionJavaFunctionClass, Date functionCreationDt, Timestamp updateDt, Collection<FunctionParameter> functionParameters)
270 {
271 final Function entity = new FunctionImpl();
272 entity.setFunctionNm(functionNm);
273 entity.setFunctionJavaFunctionClass(functionJavaFunctionClass);
274 entity.setFunctionCreationDt(functionCreationDt);
275 entity.setUpdateDt(updateDt);
276 entity.setFunctionParameters(functionParameters);
277 return entity;
278 }
279 }
280
281
282
283
284 public int compareTo(Function o)
285 {
286 int cmp = 0;
287 if (this.getFunctionId() != null)
288 {
289 cmp = this.getFunctionId().compareTo(o.getFunctionId());
290 }
291 else
292 {
293 if (this.getFunctionNm() != null)
294 {
295 cmp = (cmp != 0 ? cmp : this.getFunctionNm().compareTo(o.getFunctionNm()));
296 }
297 if (this.getFunctionJavaFunctionClass() != null)
298 {
299 cmp = (cmp != 0 ? cmp : this.getFunctionJavaFunctionClass().compareTo(o.getFunctionJavaFunctionClass()));
300 }
301 if (this.getFunctionCreationDt() != null)
302 {
303 cmp = (cmp != 0 ? cmp : this.getFunctionCreationDt().compareTo(o.getFunctionCreationDt()));
304 }
305 if (this.getUpdateDt() != null)
306 {
307 cmp = (cmp != 0 ? cmp : this.getUpdateDt().compareTo(o.getUpdateDt()));
308 }
309 }
310 return cmp;
311 }
312
313
314 }