Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016 Open Networking Foundation |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 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 | package org.onosproject.tetopology.management.api; |
| 17 | |
| 18 | /** |
| 19 | * TE optimization type. |
| 20 | */ |
| 21 | public enum OptimizationType { |
| 22 | |
| 23 | /** |
| 24 | * Designates optimization is not applied. |
| 25 | */ |
| 26 | NOT_OPTIMIZED(0), |
| 27 | |
| 28 | /** |
| 29 | * Designates optimization criteria least cost. |
| 30 | */ |
| 31 | LEAST_COST(1), |
| 32 | |
| 33 | /** |
| 34 | * Designates optimization criteria shortest delay. |
| 35 | */ |
| 36 | SHORTEST_DELAY(2), |
| 37 | |
| 38 | /** |
| 39 | * Designates optimization criteria best link utilization. |
| 40 | */ |
| 41 | BEST_LINK_UTILIZATION(3), |
| 42 | |
| 43 | /** |
| 44 | * Designates optimization criteria best link protection. |
| 45 | */ |
| 46 | BEST_LINK_PROTECTION(4); |
| 47 | |
| 48 | private int value; |
| 49 | |
| 50 | /** |
| 51 | * Creates an instance of OptimizationType. |
| 52 | * |
| 53 | * @param value value of optimization type |
| 54 | */ |
| 55 | OptimizationType(int value) { |
| 56 | this.value = value; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Returns the optimization type value. |
| 61 | * |
| 62 | * @return the value of optimization type |
| 63 | */ |
| 64 | public int value() { |
| 65 | return value; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Returns the optimization constant corresponding to the given value. |
| 70 | * If the given value cannot be mapped to any optimization type, a null |
| 71 | * is returned. |
| 72 | * |
| 73 | * @param value the value of the optimization type |
| 74 | * @return corresponding optimization type constant |
| 75 | */ |
| 76 | public static OptimizationType of(int value) { |
| 77 | switch (value) { |
| 78 | case 0: |
| 79 | return OptimizationType.NOT_OPTIMIZED; |
| 80 | case 1: |
| 81 | return OptimizationType.LEAST_COST; |
| 82 | case 2: |
| 83 | return OptimizationType.SHORTEST_DELAY; |
| 84 | case 3: |
| 85 | return OptimizationType.BEST_LINK_UTILIZATION; |
| 86 | case 4: |
| 87 | return OptimizationType.BEST_LINK_PROTECTION; |
| 88 | default: |
| 89 | return null; |
| 90 | } |
| 91 | } |
| 92 | } |