sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 1 | /* |
| 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 | package org.onosproject.isis.io.isispacket.tlv.subtlv; |
| 17 | |
| 18 | import java.util.EnumSet; |
| 19 | import java.util.HashMap; |
| 20 | import java.util.Map; |
| 21 | |
| 22 | /** |
| 23 | * Representation of sub tlv type. |
| 24 | */ |
| 25 | public enum SubTlvType { |
PRASHANTH SHIVANANJAPPA | 491b8af | 2016-04-27 19:23:24 +0530 | [diff] [blame] | 26 | /** |
| 27 | * Represents traffic engineering administrative group TLV. |
| 28 | */ |
| 29 | ADMINISTRATIVEGROUP(3), |
| 30 | /** |
| 31 | * Represents traffic engineering maximum bandwidth TLV. |
| 32 | */ |
| 33 | MAXIMUMBANDWIDTH(9), |
| 34 | /** |
| 35 | * Represents traffic engineering maximum reservable bandwidth TLV. |
| 36 | */ |
| 37 | MAXIMUMRESERVABLEBANDWIDTH(10), |
| 38 | /** |
| 39 | * Represents traffic engineering metric TLV. |
| 40 | */ |
| 41 | TRAFFICENGINEERINGMETRIC(18), |
| 42 | /** |
| 43 | * Represents traffic engineering interface address TLV. |
| 44 | */ |
| 45 | INTERFACEADDRESS(6), |
| 46 | /** |
sunish vk | 7bdf4d4 | 2016-06-24 12:29:43 +0530 | [diff] [blame^] | 47 | * Represents traffic engineering neighbor address TLV. |
| 48 | */ |
| 49 | NEIGHBORADDRESS(8), |
| 50 | /** |
PRASHANTH SHIVANANJAPPA | 491b8af | 2016-04-27 19:23:24 +0530 | [diff] [blame] | 51 | * Represents traffic engineering unreserved bandwidth TLV. |
| 52 | */ |
| 53 | UNRESERVEDBANDWIDTH(11); |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 54 | |
| 55 | // Reverse lookup table |
| 56 | private static final Map<Integer, SubTlvType> LOOKUP = new HashMap<>(); |
| 57 | |
| 58 | // Populate the lookup table on loading time |
| 59 | static { |
| 60 | for (SubTlvType subTlvType : EnumSet.allOf(SubTlvType.class)) { |
| 61 | LOOKUP.put(subTlvType.value(), subTlvType); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | private int value; |
| 66 | |
| 67 | /** |
| 68 | * Sets the sub TLV type value. |
| 69 | * |
| 70 | * @param value value. |
| 71 | */ |
| 72 | SubTlvType(int value) { |
| 73 | this.value = value; |
| 74 | } |
| 75 | |
| 76 | /** |
Dhruv Dhody | e64b93e | 2016-04-20 19:26:55 +0530 | [diff] [blame] | 77 | * Returns the enum instance from type value - reverse lookup purpose. |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 78 | * |
| 79 | * @param subTlvTypeValue TLV type value |
| 80 | * @return ISIS sub TLV type instance |
| 81 | */ |
| 82 | public static SubTlvType get(int subTlvTypeValue) { |
| 83 | return LOOKUP.get(subTlvTypeValue); |
| 84 | } |
| 85 | |
| 86 | /** |
Dhruv Dhody | e64b93e | 2016-04-20 19:26:55 +0530 | [diff] [blame] | 87 | * Returns value. |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 88 | * |
| 89 | * @return value |
| 90 | */ |
| 91 | public int value() { |
| 92 | return value; |
| 93 | } |
| 94 | } |