fcdb5e8ef56f57b1a84b357714dd1e93ec1fadda
[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  * @author herbert
20  *
21  */
22 package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes;
23
24 import javax.annotation.Nullable;
25
26 public enum InternalSeverity {
27
28         NonAlarmed,
29         Warning,
30         Minor,
31         Major,
32         Critical;
33
34     public boolean isNoAlarmIndication() {
35         return this == NonAlarmed;
36     }
37
38     public String getValueAsString() {
39         return this.name();
40     }
41
42     @Override
43     public String toString() {
44         return this.name();
45     }
46
47     public String toNetconfString()
48     {
49         switch(this)
50         {
51         case NonAlarmed:
52             return "non-alarmed";
53         case Warning:
54             return "warning";
55         case Minor:
56             return "minor";
57         case Major:
58             return "major";
59         case Critical:
60             return "critical";
61         }
62         return "not-specified";
63     }
64
65     /**
66      * convert ONF 1.2 Severity
67      * @param severity as input
68      * @return String with related output
69      */
70     public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.SeverityType severity ) {
71         switch( severity ) {
72             case NonAlarmed:
73                 return InternalSeverity.NonAlarmed;
74             case Warning:
75                 return InternalSeverity.Warning;
76             case Minor:
77                 return InternalSeverity.Minor;
78             case Major:
79                 return InternalSeverity.Major;
80             case Critical:
81                 return InternalSeverity.Critical;
82         }
83         return null;
84     }
85
86     /**
87      * convert ONF 1.2.1.1 Severity
88      * @param severity as input
89      * @return String with related output
90      */
91     public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.SeverityType severity ) {
92         switch( severity ) {
93             case NonAlarmed:
94                 return InternalSeverity.NonAlarmed;
95             case Warning:
96                 return InternalSeverity.Warning;
97             case Minor:
98                 return InternalSeverity.Minor;
99             case Major:
100                 return InternalSeverity.Major;
101             case Critical:
102                 return InternalSeverity.Critical;
103         }
104         return null;
105     }
106
107     /**
108      * convert ONF 1.2.1.1p Severity
109      * @param severity as input
110      * @return String with related output
111      */
112     public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.SeverityType severity ) {
113         switch( severity ) {
114             case NonAlarmed:
115                 return InternalSeverity.NonAlarmed;
116             case Warning:
117                 return InternalSeverity.Warning;
118             case Minor:
119                 return InternalSeverity.Minor;
120             case Major:
121                 return InternalSeverity.Major;
122             case Critical:
123                 return InternalSeverity.Critical;
124         }
125         return null;
126     }
127
128     /**
129      * convert a text string into Severity
130      * @param severityString with textes non[-]alarmed, warning minor major critical
131      * @return related enum or null
132      */
133     public static @Nullable InternalSeverity valueOfString(String severityString) {
134
135         switch( severityString.toLowerCase().trim() ) {
136         case "non-alarmed":
137         case "nonalarmed":
138                 return InternalSeverity.NonAlarmed;
139         case "warning":
140                 return InternalSeverity.Warning;
141         case "minor":
142                 return InternalSeverity.Minor;
143         case "major":
144                 return InternalSeverity.Major;
145         case "critical":
146                 return InternalSeverity.Critical;
147         }
148         return null;
149
150     }
151 }