blob: 89725400f9a0ab02bb5c4765a71ff2daa4f375b5 [file] [log] [blame]
mohamed rahil8ea09d42016-04-19 20:47:21 +05301/*
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 */
16package org.onosproject.isis.controller;
17
18import java.util.EnumSet;
19import java.util.HashMap;
20import java.util.Map;
21
22/**
23 * Representation of ISIS router types.
24 */
25public enum IsisRouterType {
26 /**
27 * Represents ISIS L1 router.
28 */
29 L1(1),
30 /**
31 * Represents ISIS L2 router.
32 */
33 L2(2),
34 /**
35 * Represents ISIS L1/L2 router.
36 */
37 L1L2(3);
38 // Reverse lookup table
39 private static final Map<Integer, IsisRouterType> LOOKUP = new HashMap<>();
40
41 // Populate the lookup table on loading time
42 static {
43 for (IsisRouterType isisRouterType : EnumSet.allOf(IsisRouterType.class)) {
44 LOOKUP.put(isisRouterType.value(), isisRouterType);
45 }
46 }
47
48 private int value;
49
50 /**
51 * Creates an instance of ISIS router type.
52 *
53 * @param value represents ISIS router type
54 */
55 private IsisRouterType(int value) {
56 this.value = value;
57 }
58
59 /**
60 * Gets the enum instance from type value - reverse lookup purpose.
61 *
62 * @param routerTypeValue router type value
63 * @return ISIS router type instance
64 */
65 public static IsisRouterType get(int routerTypeValue) {
66 return LOOKUP.get(routerTypeValue);
67 }
68
69 /**
70 * Gets the value representing router type.
71 *
72 * @return value represents router type
73 */
74 public int value() {
75 return value;
76 }
77}