blob: e9cfb43d25d786eda5a38d0aed8f75708efb262d [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;
18
19/**
20 * TE Topology type enumeration.
21 */
22public enum TeTopologyType {
23
24 /**
25 * Native topology.
26 */
27 NATIVE(0),
28
29 /**
30 * Customized topology.
31 */
32 CUSTOMIZED(1),
33
34 /**
35 * Subordinate TE topology received from SB.
36 */
37 SUBORDINATE(2),
38
39 /**
40 * Configured TE topology received from NB.
41 */
42 CONFIGURED(3),
43
44 /**
45 * ANY - default value, used for topology filtering based on topology type.
46 */
47 ANY(4);
48
49 private int teTopologyType;
50
51 /**
52 * Creates an instance of teTopologyType.
53 *
54 * @param value value of teTopologyType
55 */
56 TeTopologyType(int value) {
57 teTopologyType = value;
58 }
59
60 /**
61 * Returns the attribute teTopologyType.
62 *
63 * @return value of teTopologyType
64 */
65 public int teTopologyType() {
66 return teTopologyType;
67 }
68
69 /**
70 * Returns the object of teTopologyType from input String. Returns null
71 * when string conversion fails or value is not recognized.
72 *
73 * @param valInString input String
74 * @return Object of teTopologyType
75 */
76 public static TeTopologyType of(String valInString) {
77 try {
78 int tmpVal = Integer.parseInt(valInString);
79 return of(tmpVal);
80 } catch (Exception e) {
81 }
82 return null;
83 }
84
85 /**
86 * Returns the object of teTopologyType from input integer. Returns null
87 * when the integer value is not recognized.
88 *
89 * @param value value of teTopologyType
90 * @return Object of corresponding TE topology type
91 */
92 public static TeTopologyType of(int value) {
93 switch (value) {
94 case 0:
95 return TeTopologyType.NATIVE;
96 case 1:
97 return TeTopologyType.CUSTOMIZED;
98 case 2:
99 return TeTopologyType.SUBORDINATE;
100 case 3:
101 return TeTopologyType.CONFIGURED;
102 case 4:
103 return TeTopologyType.ANY;
104 default :
105 return null;
106 }
107 }
108}