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