cc5b8316d60e5623ea247230c8dc6809da6ca13a
[ccsdk/features.git] /
1 /*******************************************************************************
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. 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 distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  ******************************************************************************/
18 /**
19  *
20  */
21 package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes;
22
23 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.NetconfTimeStamp;
24 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.DateAndTime;
25
26 /**
27  * Converts time stamps into internal format according to ONF1.2 and ISO 8601.
28  * @author herbert
29  *
30  */
31 public class InternalDateAndTime {
32
33     private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter();
34
35     private static final InternalDateAndTime TESTPATTERN = new InternalDateAndTime("2017-01-01T00:00:00.0Z");
36
37     String internalDateAndTime;
38
39     /**
40      * Static builder ONF1.2
41      * @param time in ONF1.2 yang format
42      * @return  InternalDateAndTime
43      */
44     public static InternalDateAndTime valueOf(DateAndTime time) {
45         return new InternalDateAndTime(time);
46     }
47
48     /**
49      * Static builder ONF1.0
50      * @param time in ONF1.0 yang format
51      * @return  InternalDateAndTime
52      */
53
54     public static InternalDateAndTime valueOf(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime time) {
55         return new InternalDateAndTime(time);
56     }
57
58     /**
59      * @return     Getter with String representation
60      */
61     public String getValue() {
62         return internalDateAndTime;
63     }
64
65     /*----------------------------------------------------------------
66      * Private constructors and functions
67      */
68
69     /**
70      * Convert ONF 1.2 DateAndTime to String
71      * @param time as input
72      */
73     private InternalDateAndTime(DateAndTime time) {
74         internalDateAndTime = NETCONFTIME_CONVERTER.getTimeStampFromNetconf(time.getValue());
75     }
76
77     /**
78      * Convert ONF 1.2 DateAndTime to String
79      * @param time as input
80      */
81     private InternalDateAndTime(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime time) {
82         internalDateAndTime = NETCONFTIME_CONVERTER.getTimeStampFromNetconf(time.getValue());
83     }
84
85     /**
86      * Setup static TEST
87      * @param internalDateAndTime
88      */
89     private InternalDateAndTime(String internalDateAndTime) {
90         this.internalDateAndTime = internalDateAndTime;
91     }
92
93     /**
94      * Get a testpattern
95      * @return testpattern
96      */
97     public static InternalDateAndTime getTestpattern() {
98         return TESTPATTERN;
99     }
100
101
102
103 }