1
2
3
4
5
6 package fr.ifremer.quadrige2.core.dao.system;
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 import com.vividsolutions.jts.geom.Point;
30 import fr.ifremer.quadrige2.core.dao.data.event.Event;
31 import java.io.Serializable;
32
33
34
35
36
37 public abstract class EventPoint
38 implements Serializable, Comparable<EventPoint>
39 {
40
41
42
43 private static final long serialVersionUID = 5320667272048444733L;
44
45
46 private Integer eventId;
47
48
49
50
51
52 public Integer getEventId()
53 {
54 return this.eventId;
55 }
56
57
58
59
60
61 public void setEventId(Integer eventIdIn)
62 {
63 this.eventId = eventIdIn;
64 }
65
66 private Point eventPosition;
67
68
69
70
71
72 public Point getEventPosition()
73 {
74 return this.eventPosition;
75 }
76
77
78
79
80
81 public void setEventPosition(Point eventPositionIn)
82 {
83 this.eventPosition = eventPositionIn;
84 }
85
86
87 private Event event;
88
89
90
91
92
93 public Event getEvent()
94 {
95 return this.event;
96 }
97
98
99
100
101
102 public void setEvent(Event eventIn)
103 {
104 this.event = eventIn;
105 }
106
107
108
109
110
111 @Override
112 public boolean equals(Object object)
113 {
114 if (this == object)
115 {
116 return true;
117 }
118 if (!(object instanceof EventPoint))
119 {
120 return false;
121 }
122 final EventPoint that = (EventPoint)object;
123 if (this.eventId == null || that.getEventId() == null || !this.eventId.equals(that.getEventId()))
124 {
125 return false;
126 }
127 return true;
128 }
129
130
131
132
133 @Override
134 public int hashCode()
135 {
136 int hashCode = 0;
137 hashCode = 29 * hashCode + (this.eventId == null ? 0 : this.eventId.hashCode());
138
139 return hashCode;
140 }
141
142
143
144
145 public static final class Factory
146 {
147
148
149
150
151 public static EventPoint newInstance()
152 {
153 return new EventPointImpl();
154 }
155
156
157
158
159
160
161
162
163
164 public static EventPoint newInstance(Point eventPosition, Event event)
165 {
166 final EventPoint entity = new EventPointImpl();
167 entity.setEventPosition(eventPosition);
168 entity.setEvent(event);
169 return entity;
170 }
171 }
172
173
174
175
176 public int compareTo(EventPoint o)
177 {
178 int cmp = 0;
179 if (this.getEventId() != null)
180 {
181 cmp = this.getEventId().compareTo(o.getEventId());
182 }
183 else
184 {
185 if (this.getEventPosition() != null)
186 {
187 cmp = (cmp != 0 ? cmp : this.getEventPosition().compareTo(o.getEventPosition()));
188 }
189 }
190 return cmp;
191 }
192
193
194 }