blob: 083e6d9fbb559ce9bd05dae675b882dd35db1287 [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
46
47 /**
48 * Creates an instance of ISIS network type.
49 *
50 * @param value represents ISIS network type
51 */
52 private IsisNetworkType(int value) {
53 this.value = value;
54 }
55
56 /**
57 * Gets the enum instance from type value - reverse lookup purpose.
58 *
59 * @param isisNetworkTypeValue interface network type value
60 * @return ISIS interface network type instance
61 */
62 public static IsisNetworkType get(int isisNetworkTypeValue) {
63 return LOOKUP.get(isisNetworkTypeValue);
64 }
65
66 /**
67 * Gets the value representing network type.
68 *
69 * @return value represents network type
70 */
71 public int value() {
72 return value;
73 }
74}