blob: d4a5dc58103b574b3e513bd706dd29264900b56c [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 * Represents ISIS network types.
24 */
25public enum IsisNetworkType {
26 /**
27 * Represents point-to-point network.
28 */
29 P2P(1),
30 /**
31 * Represents broadcast network.
32 */
33 BROADCAST(2);
34 // Reverse lookup table
35 private static final Map<Integer, IsisNetworkType> LOOKUP = new HashMap<>();
36
37 // Populate the lookup table on loading time
38 static {
39 for (IsisNetworkType isisNetworkType : EnumSet.allOf(IsisNetworkType.class)) {
40 LOOKUP.put(isisNetworkType.value(), isisNetworkType);
41 }
42 }
43
44 private int value;
45
mohamed rahil8ea09d42016-04-19 20:47:21 +053046 /**
47 * Creates an instance of ISIS network type.
48 *
49 * @param value represents ISIS network type
50 */
51 private IsisNetworkType(int value) {
52 this.value = value;
53 }
54
55 /**
56 * Gets the enum instance from type value - reverse lookup purpose.
57 *
58 * @param isisNetworkTypeValue interface network type value
59 * @return ISIS interface network type instance
60 */
61 public static IsisNetworkType get(int isisNetworkTypeValue) {
62 return LOOKUP.get(isisNetworkTypeValue);
63 }
64
65 /**
66 * Gets the value representing network type.
67 *
68 * @return value represents network type
69 */
70 public int value() {
71 return value;
72 }
73}