1 /*
2 * #%L
3 * Quadrige3 Core
4 * %%
5 * Copyright (C) 2017 Ifremer
6 * %%
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * #L%
20 */
21 //
22 /**
23 * @author Generated on 07/22/2024 16:45:05+0200 Do not modify by hand!
24 *
25 * TEMPLATE: ValueObject.vsl in andromda-java-cartridge.
26 * MODEL CLASS: Données::fr.ifremer.quadrige3.core::vo::administration::strategy::AppliedPeriodVO
27 * STEREOTYPE: ValueObject
28 */
29 package fr.ifremer.quadrige3.core.vo.administration.strategy;
30
31 import java.io.Serializable;
32 import java.sql.Timestamp;
33 import java.util.Arrays;
34 import java.util.Date;
35 import org.apache.commons.lang3.builder.CompareToBuilder;
36 import org.apache.commons.lang3.builder.EqualsBuilder;
37 import org.apache.commons.lang3.builder.HashCodeBuilder;
38 import org.apache.commons.lang3.builder.ToStringBuilder;
39
40 /**
41 * Liste des périodes durant lesquels une stratégie est appliquée en un lieu.
42 */
43 public class AppliedPeriodVO
44 implements Serializable, Comparable<AppliedPeriodVO>
45 {
46 /** The serial version UID of this class. Needed for serialization. */
47 private static final long serialVersionUID = 7525651096912121704L;
48
49 // Class attributes
50 /**
51 * Date de début de la période applicable
52 */
53 protected Date appliedPeriodStartDt;
54 /**
55 * Date de fin de la période applicable. Si elle n'est pas définie, la période est en cours.
56 */
57 protected Date appliedPeriodEndDt;
58 /**
59 * Date de modification de l'objet, mise à jour par le système
60 */
61 protected Timestamp updateDt;
62 /** TODO: Model Documentation for attribute appliedStratId */
63 protected Integer appliedStratId;
64
65 // Class associationEnds
66 /**
67 * Identifie les conditions d'application locale de la stratégie pour une période donnée.
68 */
69 protected AppliedStrategyVO appliedStrategyVO;
70
71 /** Default Constructor with no properties */
72 public AppliedPeriodVO()
73 {
74 // Documented empty block - avoid compiler warning - no super constructor
75 }
76
77 /**
78 * Constructor taking only required properties
79 * @param appliedPeriodStartDtIn Date Date de début de la période applicable
80 * @param appliedPeriodEndDtIn Date Date de fin de la période applicable. Si elle n'est pas définie, la période est en cours.
81 * @param appliedStratIdIn Integer
82 * @param appliedStrategyVOIn AppliedStrategyVO Identifie les conditions d'application locale de la stratégie pour une période donnée.
83 */
84 public AppliedPeriodVO(final Date appliedPeriodStartDtIn, final Date appliedPeriodEndDtIn, final Integer appliedStratIdIn, final AppliedStrategyVO appliedStrategyVOIn)
85 {
86 this.appliedPeriodStartDt = appliedPeriodStartDtIn;
87 this.appliedPeriodEndDt = appliedPeriodEndDtIn;
88 this.appliedStratId = appliedStratIdIn;
89 this.appliedStrategyVO = appliedStrategyVOIn;
90 }
91
92 /**
93 * Constructor with all properties
94 * @param appliedPeriodStartDtIn Date
95 * @param appliedPeriodEndDtIn Date
96 * @param updateDtIn Timestamp
97 * @param appliedStratIdIn Integer
98 * @param appliedStrategyVOIn AppliedStrategyVO
99 */
100 public AppliedPeriodVO(final Date appliedPeriodStartDtIn, final Date appliedPeriodEndDtIn, final Timestamp updateDtIn, final Integer appliedStratIdIn, final AppliedStrategyVO appliedStrategyVOIn)
101 {
102 this.appliedPeriodStartDt = appliedPeriodStartDtIn;
103 this.appliedPeriodEndDt = appliedPeriodEndDtIn;
104 this.updateDt = updateDtIn;
105 this.appliedStratId = appliedStratIdIn;
106 this.appliedStrategyVO = appliedStrategyVOIn;
107 }
108
109 /**
110 * Copies constructor from other AppliedPeriodVO
111 *
112 * @param otherBean Cannot be <code>null</code>
113 * @throws NullPointerException if the argument is <code>null</code>
114 */
115 public AppliedPeriodVO(final AppliedPeriodVO otherBean)
116 {
117 this.appliedPeriodStartDt = otherBean.getAppliedPeriodStartDt();
118 this.appliedPeriodEndDt = otherBean.getAppliedPeriodEndDt();
119 this.updateDt = otherBean.getUpdateDt();
120 this.appliedStratId = otherBean.getAppliedStratId();
121 this.appliedStrategyVO = otherBean.getAppliedStrategyVO();
122 }
123
124 /**
125 * Copies all properties from the argument value object into this value object.
126 * @param otherBean Cannot be <code>null</code>
127 */
128 public void copy(final AppliedPeriodVO otherBean)
129 {
130 if (null != otherBean)
131 {
132 this.setAppliedPeriodStartDt(otherBean.getAppliedPeriodStartDt());
133 this.setAppliedPeriodEndDt(otherBean.getAppliedPeriodEndDt());
134 this.setUpdateDt(otherBean.getUpdateDt());
135 this.setAppliedStratId(otherBean.getAppliedStratId());
136 this.setAppliedStrategyVO(otherBean.getAppliedStrategyVO());
137 }
138 }
139
140 /**
141 * Date de début de la période applicable
142 * Get the appliedPeriodStartDt Attribute
143 * @return appliedPeriodStartDt Date
144 */
145 public Date getAppliedPeriodStartDt()
146 {
147 return this.appliedPeriodStartDt;
148 }
149
150 /**
151 * Date de début de la période applicable
152 * @param value Date
153 */
154 public void setAppliedPeriodStartDt(final Date value)
155 {
156 this.appliedPeriodStartDt = value;
157 }
158
159 /**
160 * Date de fin de la période applicable. Si elle n'est pas définie, la période est en cours.
161 * Get the appliedPeriodEndDt Attribute
162 * @return appliedPeriodEndDt Date
163 */
164 public Date getAppliedPeriodEndDt()
165 {
166 return this.appliedPeriodEndDt;
167 }
168
169 /**
170 * Date de fin de la période applicable. Si elle n'est pas définie, la période est en cours.
171 * @param value Date
172 */
173 public void setAppliedPeriodEndDt(final Date value)
174 {
175 this.appliedPeriodEndDt = value;
176 }
177
178 /**
179 * Date de modification de l'objet, mise à jour par le système
180 * Get the updateDt Attribute
181 * @return updateDt Timestamp
182 */
183 public Timestamp getUpdateDt()
184 {
185 return this.updateDt;
186 }
187
188 /**
189 * Date de modification de l'objet, mise à jour par le système
190 * @param value Timestamp
191 */
192 public void setUpdateDt(final Timestamp value)
193 {
194 this.updateDt = value;
195 }
196
197 /**
198 * TODO: Model Documentation for attribute appliedStratId
199 * Get the appliedStratId Attribute
200 * @return appliedStratId Integer
201 */
202 public Integer getAppliedStratId()
203 {
204 return this.appliedStratId;
205 }
206
207 /**
208 *
209 * @param value Integer
210 */
211 public void setAppliedStratId(final Integer value)
212 {
213 this.appliedStratId = value;
214 }
215
216 /**
217 * Identifie les conditions d'application locale de la stratégie pour une période donnée.
218 * Get the appliedStrategyVO Association
219 * @return this.appliedStrategyVO AppliedStrategyVO
220 */
221 public AppliedStrategyVO getAppliedStrategyVO()
222 {
223 return this.appliedStrategyVO;
224 }
225
226 /**
227 * Sets the appliedStrategyVO
228 * @param value AppliedStrategyVO
229 */
230 public void setAppliedStrategyVO(AppliedStrategyVO value)
231 {
232 this.appliedStrategyVO = value;
233 }
234
235 /**
236 * @param object to compare this object against
237 * @return boolean if equal
238 * @see Object#equals(Object)
239 */
240 @Override
241 public boolean equals(final Object object)
242 {
243 if (object==null || object.getClass() != this.getClass())
244 {
245 return false;
246 }
247 // Check if the same object instance
248 if (object==this)
249 {
250 return true;
251 }
252 AppliedPeriodVO rhs = (AppliedPeriodVO) object;
253 return new EqualsBuilder()
254 .append(this.getAppliedPeriodStartDt(), rhs.getAppliedPeriodStartDt())
255 .append(this.getAppliedPeriodEndDt(), rhs.getAppliedPeriodEndDt())
256 .append(this.getUpdateDt(), rhs.getUpdateDt())
257 .append(this.getAppliedStratId(), rhs.getAppliedStratId())
258 .append(this.getAppliedStrategyVO(), rhs.getAppliedStrategyVO())
259 .isEquals();
260 }
261
262 /**
263 * @param object to compare this object against
264 * @return int if equal
265 * @see Comparable#compareTo(Object)
266 */
267 public int compareTo(final AppliedPeriodVO object)
268 {
269 if (object==null)
270 {
271 return -1;
272 }
273 // Check if the same object instance
274 if (object==this)
275 {
276 return 0;
277 }
278 return new CompareToBuilder()
279 .append(this.getAppliedPeriodStartDt(), object.getAppliedPeriodStartDt())
280 .append(this.getAppliedPeriodEndDt(), object.getAppliedPeriodEndDt())
281 .append(this.getUpdateDt(), object.getUpdateDt())
282 .append(this.getAppliedStratId(), object.getAppliedStratId())
283 .append(this.getAppliedStrategyVO(), object.getAppliedStrategyVO())
284 .toComparison();
285 }
286
287 /**
288 * @return int hashCode value
289 * @see Object#hashCode()
290 */
291 @Override
292 public int hashCode()
293 {
294 return new HashCodeBuilder(1249046965, -82296885)
295 .append(this.getAppliedPeriodStartDt())
296 .append(this.getAppliedPeriodEndDt())
297 .append(this.getUpdateDt())
298 .append(this.getAppliedStratId())
299 .append(this.getAppliedStrategyVO())
300 .toHashCode();
301 }
302
303 /**
304 * @return String representation of object
305 * @see Object#toString()
306 */
307 @Override
308 public String toString()
309 {
310 return new ToStringBuilder(this)
311 .append("appliedPeriodStartDt", this.getAppliedPeriodStartDt())
312 .append("appliedPeriodEndDt", this.getAppliedPeriodEndDt())
313 .append("updateDt", this.getUpdateDt())
314 .append("appliedStratId", this.getAppliedStratId())
315 .append("appliedStrategyVO", this.getAppliedStrategyVO())
316 .toString();
317 }
318
319 /**
320 * This is a convenient helper method which is able to detect whether or not two values are equal. Two values
321 * are equal when they are both {@code null}, are arrays of the same length with equal elements or are
322 * equal objects (this includes {@link java.util.Collection} and {@link java.util.Map} instances).
323 *
324 * <p/>Note that for array, collection or map instances the comparison runs one level deep.
325 *
326 * @param first the first object to compare, may be {@code null}
327 * @param second the second object to compare, may be {@code null}
328 * @return this method will return {@code true} in case both objects are equal as explained above;
329 * in all other cases this method will return {@code false}
330 */
331 protected static boolean equal(final Object first, final Object second)
332 {
333 final boolean equal;
334
335 if (first == null)
336 {
337 equal = (second == null);
338 }
339 else if (first.getClass().isArray() && (second != null) && second.getClass().isArray())
340 {
341 equal = Arrays.equals((Object[])first, (Object[])second);
342 }
343 else // note that the following also covers java.util.Collection and java.util.Map
344 {
345 equal = first.equals(second);
346 }
347
348 return equal;
349 }
350
351 // AppliedPeriodVO value-object java merge-point
352 }