15bd0232f628467bfb7dfe9cf7a3b4cb395e6579
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.apex.context.test.concepts;
22
23 import java.io.Serializable;
24 import java.util.TimeZone;
25
26 /**
27  * The Class TestContextItem009.
28  */
29 public class TestContextDateTzItem implements Serializable {
30     private static final long serialVersionUID = 5604426823170331706L;
31
32     private static final int HASH_PRIME_1 = 31;
33     private static final int HASH_PRIME_2 = 1231;
34     private static final int HASH_PRIME_3 = 1237;
35
36     private TestContextDateItem dateValue = new TestContextDateItem(System.currentTimeMillis());
37     private String timeZoneString = TimeZone.getTimeZone("Europe/Dublin").getDisplayName();
38     private boolean dst = false;
39
40     /**
41      * The Constructor.
42      */
43     public TestContextDateTzItem() {
44         dst = true;
45     }
46
47     /**
48      * The Constructor.
49      *
50      * @param dateValue the date value
51      * @param tzValue the tz value
52      * @param dst the dst
53      */
54     public TestContextDateTzItem(final TestContextDateItem dateValue, final String tzValue, final boolean dst) {
55         this.dateValue = dateValue;
56         this.timeZoneString = TimeZone.getTimeZone(tzValue).getDisplayName();
57         this.dst = dst;
58     }
59
60     /**
61      * The Constructor.
62      *
63      * @param original the original
64      */
65     public TestContextDateTzItem(final TestContextDateTzItem original) {
66         this.dateValue = original.dateValue;
67         this.timeZoneString = original.timeZoneString;
68         this.dst = original.dst;
69     }
70
71     /**
72      * Gets the date value.
73      *
74      * @return the date value
75      */
76     public TestContextDateItem getDateValue() {
77         return dateValue;
78     }
79
80     /**
81      * Sets the date value.
82      *
83      * @param dateValue the date value
84      */
85     public void setDateValue(final TestContextDateItem dateValue) {
86         this.dateValue = dateValue;
87     }
88
89     /**
90      * Gets the TZ value.
91      *
92      * @return the TZ value
93      */
94     public String getTzValue() {
95         return timeZoneString;
96     }
97
98     /**
99      * Sets the TZ value.
100      *
101      * @param tzValue the TZ value
102      */
103     public void setTzValue(final String tzValue) {
104         if (tzValue != null) {
105             this.timeZoneString = TimeZone.getTimeZone(tzValue).getDisplayName();
106         }
107         else {
108             this.timeZoneString = null;
109         }
110     }
111
112     /**
113      * Gets the DST.
114      *
115      * @return the dst
116      */
117     public boolean getDst() {
118         return dst;
119     }
120
121     /**
122      * Sets the DST.
123      *
124      * @param newDst the dst
125      */
126     public void setDst(final boolean newDst) {
127         this.dst = newDst;
128     }
129
130     /*
131      * (non-Javadoc)
132      *
133      * @see java.lang.Object#hashCode()
134      */
135     @Override
136     public int hashCode() {
137         final int prime = HASH_PRIME_1;
138         int result = 1;
139         result = prime * result + ((dateValue == null) ? 0 : dateValue.hashCode());
140         result = prime * result + (dst ? HASH_PRIME_2 : HASH_PRIME_3);
141         result = prime * result + ((timeZoneString == null) ? 0 : timeZoneString.hashCode());
142         return result;
143     }
144
145     /*
146      * (non-Javadoc)
147      *
148      * @see java.lang.Object#equals(java.lang.Object)
149      */
150     @Override
151     public boolean equals(final Object obj) {
152         if (this == obj) {
153             return true;
154         }
155         if (obj == null) {
156             return false;
157         }
158         if (getClass() != obj.getClass()) {
159             return false;
160         }
161         final TestContextDateTzItem other = (TestContextDateTzItem) obj;
162         if (dateValue == null) {
163             if (other.dateValue != null) {
164                 return false;
165             }
166         } else if (!dateValue.equals(other.dateValue)) {
167             return false;
168         }
169         if (dst != other.dst) {
170             return false;
171         }
172         if (timeZoneString == null) {
173             if (other.timeZoneString != null) {
174                 return false;
175             }
176         }
177         else if (!timeZoneString.equals(other.timeZoneString)) {
178             return false;
179         }
180         return true;
181     }
182
183     /*
184      * (non-Javadoc)
185      *
186      * @see java.lang.Object#toString()
187      */
188     @Override
189     public String toString() {
190         return "TestContextItem009 [dateValue=" + dateValue + ", tzValue=" + timeZoneString + ", dst=" + dst + "]";
191     }
192 }