a3d2fc4751d7cb281a4e95f667fd4ce3edbc0c92
[policy/apex-pdp.git] / testsuites / integration / integration-common / src / main / java / org / onap / policy / apex / context / test / concepts / TestContextDateLocaleItem.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  *  Modifications Copyright (C) 2019-2020 Nordix Foundation.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.apex.context.test.concepts;
23
24 import java.io.Serializable;
25 import java.util.Locale;
26 import java.util.TimeZone;
27
28 import lombok.Data;
29
30 /**
31  * The Class TestContextDateLocaleItem.
32  */
33 @Data
34 public class TestContextDateLocaleItem implements Serializable {
35     private static final long serialVersionUID = -6579903685538233754L;
36
37     private TestContextDateItem dateValue = new TestContextDateItem(System.currentTimeMillis());
38     private String tzValue = TimeZone.getTimeZone("Europe/Dublin").getDisplayName();
39     private boolean dst = false;
40     private int utcOffset = 0;
41     private Locale locale = Locale.ENGLISH;
42
43     /**
44      * The Constructor.
45      */
46     public TestContextDateLocaleItem() {
47     }
48
49     /**
50      * The Constructor.
51      *
52      * @param dateValue the date value
53      * @param tzValue the tz value
54      * @param dst the dst
55      * @param utcOffset the utc offset
56      * @param language the language
57      * @param country the country
58      */
59     public TestContextDateLocaleItem(final TestContextDateItem dateValue, final String tzValue, final boolean dst,
60             final int utcOffset, final String language, final String country) {
61         this.dateValue = dateValue;
62         this.tzValue = TimeZone.getTimeZone(tzValue).getDisplayName();
63         this.dst = dst;
64         this.utcOffset = utcOffset;
65
66         this.locale = new Locale(language, country);
67     }
68
69     /**
70      * The Constructor.
71      *
72      * @param original the original
73      */
74     public TestContextDateLocaleItem(final TestContextDateLocaleItem original) {
75         this.dateValue = original.dateValue;
76         this.tzValue = TimeZone.getTimeZone(original.tzValue).getDisplayName();
77         this.dst = original.dst;
78         this.utcOffset = original.utcOffset;
79
80         this.locale = new Locale(original.getLocale().getCountry(), original.getLocale().getLanguage());
81     }
82
83     /**
84      * Sets the TZ value.
85      *
86      * @param tzValue the TZ value
87      */
88     public void setTzValue(final String tzValue) {
89         if (tzValue != null) {
90             this.tzValue = TimeZone.getTimeZone(tzValue).getDisplayName();
91         } else {
92             this.tzValue = null;
93         }
94     }
95 }