blob: 59296bc29ee7d04b8caa444686b9ece55b87f609 [file] [log] [blame]
Aihua Guo1ce2dd12016-08-12 23:37:44 -04001/*
2 * Copyright 2016-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.tetopology.management.api.node;
18
19/**
20 * Represents ENUM data of teStatus.
21 */
22public enum TeStatus {
23
24 /**
25 * Represents up.
26 */
27 UP(0),
28
29 /**
30 * Represents down.
31 */
32 DOWN(1),
33
34 /**
35 * Represents testing.
36 */
37 TESTING(2),
38
39 /**
40 * Represents preparingMaintenance.
41 */
42 PREPARING_MAINTENANCE(3),
43
44 /**
45 * Represents maintenance.
46 */
47 MAINTENANCE(4),
48
49 /**
50 * Status cannot be determined for some reason.
51 */
52 UNKNOWN(5);
53
54 private int teStatus;
55
56 /**
57 * Creates an instance of teStatus.
58 *
59 * @param value value of teStatus
60 */
61 TeStatus(int value) {
62 teStatus = value;
63 }
64
65 /**
66 * Returns the attribute teStatus.
67 *
68 * @return value of teStatus
69 */
70 public int teStatus() {
71 return teStatus;
72 }
73
74 /**
75 * Returns the object of teStatus fromString input String. Returns null
76 * when the integer value is not recognized.
77 *
78 * @param valInString input String
79 * @return Object of teStatus
80 */
81 public static TeStatus of(String valInString) {
82 try {
83 int tmpVal = Integer.parseInt(valInString);
84 return of(tmpVal);
85 } catch (NumberFormatException e) {
86 }
87 return null;
88 }
89
90 /**
91 * Returns the object of teAdminStatusEnumForTypeInt.Returns null
92 * when string conversion fails or converted integer value is not
93 * recognized.
94 *
95 * @param value value of teAdminStatusEnumForTypeInt
96 * @return Object of teAdminStatusEnumForTypeInt
97 */
98 public static TeStatus of(int value) {
99 switch (value) {
100 case 0:
101 return TeStatus.UP;
102 case 1:
103 return TeStatus.DOWN;
104 case 2:
105 return TeStatus.TESTING;
106 case 3:
107 return TeStatus.PREPARING_MAINTENANCE;
108 case 4:
109 return TeStatus.MAINTENANCE;
110 case 5:
111 return TeStatus.UNKNOWN;
112 default :
113 return null;
114 }
115 }
116}