blob: 6fd34f578c105bf9948d403023852c142c66fc6b [file] [log] [blame]
Aihua Guo1ce2dd12016-08-12 23:37:44 -04001/*
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.link;
17
18/**
19 * Represents ENUM data of teLinkAccessType.
20 */
21public enum TeLinkAccessType {
22 /**
23 * Represents pointToPoint.
24 */
25 POINT_TO_POINT(0),
26
27 /**
28 * Represents multiAccess.
29 */
30 MULTI_ACCESS(1);
31
32 private int teLinkAccessType;
33
34 TeLinkAccessType(int value) {
35 teLinkAccessType = value;
36 }
37
38 /**
39 * Returns the attribute teLinkAccessType.
40 *
41 * @return value of teLinkAccessType
42 */
43 public int teLinkAccessType() {
44 return teLinkAccessType;
45 }
46
47 /**
48 * Returns the object of teLinkAccessType from input String. Returns null
49 * when string conversion fails or converted integer value is not recognized.
50 *
51 * @param valInString input String
52 * @return Object of teLinkAccessType
53 */
54 public static TeLinkAccessType of(String valInString) {
55 try {
56 int tmpVal = Integer.parseInt(valInString);
57 return of(tmpVal);
58 } catch (NumberFormatException e) {
59 }
60 return null;
61 }
62
63 /**
64 * Returns the object of teLinkAccessTypeForTypeInt. Returns null
65 * when the integer value is not recognized.
66 *
67 * @param value value of teLinkAccessTypeForTypeInt
68 * @return Object of teLinkAccessTypeForTypeInt
69 */
70 public static TeLinkAccessType of(int value) {
71 switch (value) {
72 case 0:
73 return TeLinkAccessType.POINT_TO_POINT;
74 case 1:
75 return TeLinkAccessType.MULTI_ACCESS;
76 default :
77 return null;
78 }
79 }
80
81}