blob: fc7ea5ee32ce28f625ae277952dc2cb076702df4 [file] [log] [blame]
Henry Yu4b4a7eb2016-11-09 20:07:53 -05001/*
2 * Copyright 2016 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 */
16package org.onosproject.tetopology.management.api;
17
18/**
19 * LSP encoding type.
20 * See RFC 3471 for details.
21 */
22public enum EncodingType {
23
24 /**
25 * Designates Packet LSP encoding.
26 */
27 LSP_ENCODING_PACKET(1),
28
29 /**
30 * Designates Ethernet LSP encoding.
31 */
32 LSP_ENCODING_ETHERNET(2),
33
34 /**
35 * Designates ANSI/ETSI PDH encoding.
36 */
37 LSP_ENCODING_PDH(3),
38
39 /**
40 * Designates SDH ITU-T G.707 / SONET ANSI T1.105 LSP encoding.
41 */
42 LSP_ENCODING_SDH(5),
43
44 /**
45 * Designates Digital Wrapper LSP encoding.
46 */
47 LSP_ENCODING_DIGITAL_WRAPPER(7),
48
49 /**
50 * Designates Lambda (photonic) LSP encoding.
51 */
52 LSP_ENCODING_LAMBDA(8),
53
54 /**
55 * Designates Fiber LSP encoding.
56 */
57 LSP_ENCODING_FIBER(9),
58
59 /**
60 * Designates Fiber Channel LSP encoding.
61 */
62 LSP_ENCODING_FIBER_CHANNEL(11),
63
64 /**
65 * Designates G.709 ODUk (Digital Path)LSP encoding.
66 */
67 LSP_ENCODING_ODUK(12);
68
69 private int value;
70
71 /**
72 * Creates an instance of EncodingType.
73 *
74 * @param value value of encoding type
75 */
76 EncodingType(int value) {
77 this.value = value;
78 }
79
80 /**
81 * Returns the corresponding integer value of the encoding type.
82 *
83 * @return corresponding integer value
84 */
85 public int value() {
86 return value;
87 }
88
89 /**
90 * Returns the encoding type constant corresponding to the given integer
91 * value. If the given value cannot be mapped to any valid encoding type,
92 * a null is returned.
93 *
94 * @param value integer value
95 * @return corresponding encoding type constant
96 */
97 public static EncodingType of(int value) {
98 switch (value) {
99 case 1:
100 return LSP_ENCODING_PACKET;
101 case 2:
102 return LSP_ENCODING_ETHERNET;
103 case 3:
104 return LSP_ENCODING_PDH;
105 case 5:
106 return LSP_ENCODING_SDH;
107 case 7:
108 return LSP_ENCODING_DIGITAL_WRAPPER;
109 case 8:
110 return LSP_ENCODING_LAMBDA;
111 case 9:
112 return LSP_ENCODING_FIBER;
113 case 11:
114 return LSP_ENCODING_FIBER_CHANNEL;
115 case 12:
116 return LSP_ENCODING_ODUK;
117 default:
118 return null;
119 }
120 }
121}