1
2
3
4
5
6 package fr.ifremer.quadrige2.core.dao.referential.taxon;
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 import fr.ifremer.quadrige2.core.dao.referential.Status;
30 import java.io.Serializable;
31 import java.sql.Timestamp;
32 import java.util.Collection;
33 import java.util.Date;
34 import java.util.HashSet;
35
36
37
38
39
40 public abstract class Citation
41 implements Serializable, Comparable<Citation>
42 {
43
44
45
46 private static final long serialVersionUID = -1076349412632982927L;
47
48
49 private Integer citId;
50
51
52
53
54
55 public Integer getCitId()
56 {
57 return this.citId;
58 }
59
60
61
62
63
64 public void setCitId(Integer citIdIn)
65 {
66 this.citId = citIdIn;
67 }
68
69 private String citNm;
70
71
72
73
74
75 public String getCitNm()
76 {
77 return this.citNm;
78 }
79
80
81
82
83
84 public void setCitNm(String citNmIn)
85 {
86 this.citNm = citNmIn;
87 }
88
89 private Date citCreationDt;
90
91
92
93
94
95 public Date getCitCreationDt()
96 {
97 return this.citCreationDt;
98 }
99
100
101
102
103
104 public void setCitCreationDt(Date citCreationDtIn)
105 {
106 this.citCreationDt = citCreationDtIn;
107 }
108
109 private Timestamp updateDt;
110
111
112
113
114
115 public Timestamp getUpdateDt()
116 {
117 return this.updateDt;
118 }
119
120
121
122
123
124 public void setUpdateDt(Timestamp updateDtIn)
125 {
126 this.updateDt = updateDtIn;
127 }
128
129
130 private Collection<TaxonName> taxonNames = new HashSet<TaxonName>();
131
132
133
134
135
136 public Collection<TaxonName> getTaxonNames()
137 {
138 return this.taxonNames;
139 }
140
141
142
143
144
145 public void setTaxonNames(Collection<TaxonName> taxonNamesIn)
146 {
147 this.taxonNames = taxonNamesIn;
148 }
149
150
151
152
153
154
155
156 public boolean addTaxonNames(TaxonName elementToAdd)
157 {
158 return this.taxonNames.add(elementToAdd);
159 }
160
161
162
163
164
165
166
167 public boolean removeTaxonNames(TaxonName elementToRemove)
168 {
169 return this.taxonNames.remove(elementToRemove);
170 }
171
172 private Status status;
173
174
175
176
177
178 public Status getStatus()
179 {
180 return this.status;
181 }
182
183
184
185
186
187 public void setStatus(Status statusIn)
188 {
189 this.status = statusIn;
190 }
191
192 private Collection<TaxonNameHistory> taxonNameHistIds = new HashSet<TaxonNameHistory>();
193
194
195
196
197
198 public Collection<TaxonNameHistory> getTaxonNameHistIds()
199 {
200 return this.taxonNameHistIds;
201 }
202
203
204
205
206
207 public void setTaxonNameHistIds(Collection<TaxonNameHistory> taxonNameHistIdsIn)
208 {
209 this.taxonNameHistIds = taxonNameHistIdsIn;
210 }
211
212
213
214
215
216
217
218 public boolean addTaxonNameHistIds(TaxonNameHistory elementToAdd)
219 {
220 return this.taxonNameHistIds.add(elementToAdd);
221 }
222
223
224
225
226
227
228
229 public boolean removeTaxonNameHistIds(TaxonNameHistory elementToRemove)
230 {
231 return this.taxonNameHistIds.remove(elementToRemove);
232 }
233
234
235
236
237
238 @Override
239 public boolean equals(Object object)
240 {
241 if (this == object)
242 {
243 return true;
244 }
245 if (!(object instanceof Citation))
246 {
247 return false;
248 }
249 final Citation that = (Citation)object;
250 if (this.citId == null || that.getCitId() == null || !this.citId.equals(that.getCitId()))
251 {
252 return false;
253 }
254 return true;
255 }
256
257
258
259
260 @Override
261 public int hashCode()
262 {
263 int hashCode = 0;
264 hashCode = 29 * hashCode + (this.citId == null ? 0 : this.citId.hashCode());
265
266 return hashCode;
267 }
268
269
270
271
272 public static final class Factory
273 {
274
275
276
277
278 public static Citation newInstance()
279 {
280 return new CitationImpl();
281 }
282
283
284
285
286
287
288
289
290 public static Citation newInstance(Timestamp updateDt, Status status)
291 {
292 final Citation entity = new CitationImpl();
293 entity.setUpdateDt(updateDt);
294 entity.setStatus(status);
295 return entity;
296 }
297
298
299
300
301
302
303
304
305
306
307
308
309 public static Citation newInstance(String citNm, Date citCreationDt, Timestamp updateDt, Collection<TaxonName> taxonNames, Status status, Collection<TaxonNameHistory> taxonNameHistIds)
310 {
311 final Citation entity = new CitationImpl();
312 entity.setCitNm(citNm);
313 entity.setCitCreationDt(citCreationDt);
314 entity.setUpdateDt(updateDt);
315 entity.setTaxonNames(taxonNames);
316 entity.setStatus(status);
317 entity.setTaxonNameHistIds(taxonNameHistIds);
318 return entity;
319 }
320 }
321
322
323
324
325 public int compareTo(Citation o)
326 {
327 int cmp = 0;
328 if (this.getCitId() != null)
329 {
330 cmp = this.getCitId().compareTo(o.getCitId());
331 }
332 else
333 {
334 if (this.getCitNm() != null)
335 {
336 cmp = (cmp != 0 ? cmp : this.getCitNm().compareTo(o.getCitNm()));
337 }
338 if (this.getCitCreationDt() != null)
339 {
340 cmp = (cmp != 0 ? cmp : this.getCitCreationDt().compareTo(o.getCitCreationDt()));
341 }
342 if (this.getUpdateDt() != null)
343 {
344 cmp = (cmp != 0 ? cmp : this.getUpdateDt().compareTo(o.getUpdateDt()));
345 }
346 }
347 return cmp;
348 }
349
350
351 }