Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [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 | |
| 17 | package org.onosproject.tetopology.management.api.link; |
| 18 | |
| 19 | /** |
| 20 | * Represents ENUM data of linkProtectionType. |
| 21 | */ |
| 22 | public enum LinkProtectionType { |
| 23 | |
| 24 | /** |
| 25 | * Represents unprotected. |
| 26 | */ |
| 27 | UNPROTECTED(0), |
| 28 | |
| 29 | /** |
| 30 | * Represents extraTraffic. |
| 31 | */ |
| 32 | EXTRA_TRAFFIC(1), |
| 33 | |
| 34 | /** |
| 35 | * Represents shared. |
| 36 | */ |
| 37 | SHARED(2), |
| 38 | |
| 39 | /** |
| 40 | * Represents yangAutoPrefix1For1. |
| 41 | */ |
| 42 | YANGAUTOPREFIX1_FOR_1(3), |
| 43 | |
| 44 | /** |
| 45 | * Represents yangAutoPrefix1Plus1. |
| 46 | */ |
| 47 | YANGAUTOPREFIX1_PLUS_1(4), |
| 48 | |
| 49 | /** |
| 50 | * Represents enhanced. |
| 51 | */ |
| 52 | ENHANCED(5); |
| 53 | |
| 54 | private int linkProtectionType; |
| 55 | |
| 56 | LinkProtectionType(int value) { |
| 57 | linkProtectionType = value; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Returns the attribute linkProtectionType. |
| 62 | * |
| 63 | * @return value of linkProtectionType |
| 64 | */ |
| 65 | public int linkProtectionType() { |
| 66 | return linkProtectionType; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Returns the object of linkProtectionType from input String. Returns null |
| 71 | * when string conversion fails or converted integer value is not recognized. |
| 72 | * |
| 73 | * @param valInString input String |
| 74 | * @return Object of linkProtectionType |
| 75 | */ |
| 76 | public static LinkProtectionType of(String valInString) { |
| 77 | try { |
| 78 | int tmpVal = Integer.parseInt(valInString); |
| 79 | return of(tmpVal); |
| 80 | } catch (NumberFormatException e) { |
| 81 | } |
| 82 | return null; |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Returns the object of linkProtectionType from input integer. Returns null |
| 87 | * when the integer value is not recognized. |
| 88 | * |
| 89 | * @param value value of linkProtectionTypeForTypeInt |
| 90 | * @return Object of linkProtectionTypeForTypeInt |
| 91 | */ |
| 92 | public static LinkProtectionType of(int value) { |
| 93 | switch (value) { |
| 94 | case 0: |
| 95 | return LinkProtectionType.UNPROTECTED; |
| 96 | case 1: |
| 97 | return LinkProtectionType.EXTRA_TRAFFIC; |
| 98 | case 2: |
| 99 | return LinkProtectionType.SHARED; |
| 100 | case 3: |
| 101 | return LinkProtectionType.YANGAUTOPREFIX1_FOR_1; |
| 102 | case 4: |
| 103 | return LinkProtectionType.YANGAUTOPREFIX1_PLUS_1; |
| 104 | case 5: |
| 105 | return LinkProtectionType.ENHANCED; |
| 106 | default : |
| 107 | return null; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | |
| 112 | } |