7d3ed80d5fbbcc9fd2f1fa424ca38709b1c3a2ca
[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         this.timeZoneString = TimeZone.getTimeZone(tzValue).getDisplayName();
105     }
106
107     /**
108      * Gets the DST.
109      *
110      * @return the dst
111      */
112     public boolean getDST() {
113         return dst;
114     }
115
116     /**
117      * Sets the DST.
118      *
119      * @param newDst the dst
120      */
121     public void setDST(final boolean newDst) {
122         this.dst = newDst;
123     }
124
125     /*
126      * (non-Javadoc)
127      *
128      * @see java.lang.Object#hashCode()
129      */
130     @Override
131     public int hashCode() {
132         final int prime = HASH_PRIME_1;
133         int result = 1;
134         result = prime * result + ((dateValue == null) ? 0 : dateValue.hashCode());
135         result = prime * result + (dst ? HASH_PRIME_2 : HASH_PRIME_3);
136         result = prime * result + ((timeZoneString == null) ? 0 : timeZoneString.hashCode());
137         return result;
138     }
139
140     /*
141      * (non-Javadoc)
142      *
143      * @see java.lang.Object#equals(java.lang.Object)
144      */
145     @Override
146     public boolean equals(final Object obj) {
147         if (this == obj) {
148             return true;
149         }
150         if (obj == null) {
151             return false;
152         }
153         if (getClass() != obj.getClass()) {
154             return false;
155         }
156         final TestContextDateTzItem other = (TestContextDateTzItem) obj;
157         if (dateValue == null) {
158             if (other.dateValue != null) {
159                 return false;
160             }
161         } else if (!dateValue.equals(other.dateValue)) {
162             return false;
163         }
164         if (dst != other.dst) {
165             return false;
166         }
167         if (timeZoneString == null) {
168             if (other.timeZoneString != null) {
169                 return false;
170             }
171         } else if (!timeZoneString.equals(other.timeZoneString)) {
172             return false;
173         }
174         return true;
175     }
176
177     /*
178      * (non-Javadoc)
179      *
180      * @see java.lang.Object#toString()
181      */
182     @Override
183     public String toString() {
184         return "TestContextItem009 [dateValue=" + dateValue + ", tzValue=" + timeZoneString + ", dst=" + dst + "]";
185     }
186 }