Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame] | 2 | * Copyright 2014-2015 Open Networking Laboratory |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net; |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 17 | |
| 18 | /** |
| 19 | * Collection of keys for annotation. |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 20 | * <p> |
| 21 | * Number of the annotation keys have been deprecated as the use of annotations |
| 22 | * is being phased out and instead network configuration subsystem is being |
| 23 | * phased-in for majority of model meta-data. |
| 24 | * </p> |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 25 | */ |
| 26 | public final class AnnotationKeys { |
| 27 | |
| 28 | // Prohibit instantiation |
| 29 | private AnnotationKeys() {} |
| 30 | |
| 31 | /** |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 32 | * Annotation key for instance name. |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 33 | * |
| 34 | * @deprecated since Cardinal |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 35 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 36 | @Deprecated |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 37 | public static final String NAME = "name"; |
| 38 | |
| 39 | /** |
| 40 | * Annotation key for instance type (e.g. host type). |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 41 | * |
| 42 | * @deprecated since Cardinal |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 43 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 44 | @Deprecated |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 45 | public static final String TYPE = "type"; |
| 46 | |
| 47 | /** |
| 48 | * Annotation key for latitude (e.g. latitude of device). |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 49 | * |
| 50 | * @deprecated since Cardinal |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 51 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 52 | @Deprecated |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 53 | public static final String LATITUDE = "latitude"; |
| 54 | |
| 55 | /** |
| 56 | * Annotation key for longitute (e.g. longitude of device). |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 57 | * |
| 58 | * @deprecated since Cardinal |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 59 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 60 | @Deprecated |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 61 | public static final String LONGITUDE = "longitude"; |
| 62 | |
| 63 | /** |
| 64 | * Annotation key for southbound protocol. |
| 65 | */ |
| 66 | public static final String PROTOCOL = "protocol"; |
| 67 | |
| 68 | /** |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 69 | * Annotation key for the device driver name. |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 70 | * |
| 71 | * @deprecated since Cardinal |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 72 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 73 | @Deprecated |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 74 | public static final String DRIVER = "driver"; |
| 75 | |
| 76 | /** |
Thomas Vachuska | 57126fe | 2014-11-11 17:13:24 -0800 | [diff] [blame] | 77 | * Annotation key for durable links. |
| 78 | */ |
| 79 | public static final String DURABLE = "durable"; |
| 80 | |
| 81 | /** |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 82 | * Annotation key for latency. |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 83 | * |
| 84 | * @deprecated since Cardinal |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 85 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 86 | @Deprecated |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 87 | public static final String LATENCY = "latency"; |
Sho SHIMIZU | 97a64cd | 2014-11-11 16:31:21 -0800 | [diff] [blame] | 88 | |
| 89 | /** |
Toshio Koide | 4b6562b | 2014-11-13 17:20:47 -0800 | [diff] [blame] | 90 | * Annotation key for bandwidth. |
Sho SHIMIZU | 0ce220a | 2015-01-23 15:54:47 -0800 | [diff] [blame] | 91 | * The value for this key is interpreted as Mbps. |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 92 | * |
| 93 | * @deprecated since Cardinal |
Toshio Koide | 4b6562b | 2014-11-13 17:20:47 -0800 | [diff] [blame] | 94 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 95 | @Deprecated |
Toshio Koide | 4b6562b | 2014-11-13 17:20:47 -0800 | [diff] [blame] | 96 | public static final String BANDWIDTH = "bandwidth"; |
| 97 | |
| 98 | /** |
| 99 | * Annotation key for the number of optical waves. |
| 100 | */ |
| 101 | public static final String OPTICAL_WAVES = "optical.waves"; |
| 102 | |
| 103 | /** |
Thomas Vachuska | b52a014 | 2015-04-21 17:48:15 -0700 | [diff] [blame] | 104 | * Annotation key for the port name. |
| 105 | */ |
| 106 | public static final String PORT_NAME = "portName"; |
| 107 | |
Simon Hunt | ab130524 | 2015-05-06 18:07:13 -0700 | [diff] [blame] | 108 | /** |
| 109 | * Annotation key for the router ID. |
| 110 | */ |
| 111 | public static final String ROUTER_ID = "routerId"; |
Thomas Vachuska | b52a014 | 2015-04-21 17:48:15 -0700 | [diff] [blame] | 112 | |
Marc De Leenheer | 723f553 | 2015-06-03 20:16:17 -0700 | [diff] [blame] | 113 | public static final String STATIC_LAMBDA = "staticLambda"; |
| 114 | |
| 115 | public static final String STATIC_PORT = "staticPort"; |
| 116 | |
Thomas Vachuska | b52a014 | 2015-04-21 17:48:15 -0700 | [diff] [blame] | 117 | /** |
Sho SHIMIZU | 97a64cd | 2014-11-11 16:31:21 -0800 | [diff] [blame] | 118 | * Returns the value annotated object for the specified annotation key. |
| 119 | * The annotated value is expected to be String that can be parsed as double. |
| 120 | * If parsing fails, the returned value will be 1.0. |
| 121 | * |
| 122 | * @param annotated annotated object whose annotated value is obtained |
| 123 | * @param key key of annotation |
| 124 | * @return double value of annotated object for the specified key |
| 125 | */ |
| 126 | public static double getAnnotatedValue(Annotated annotated, String key) { |
| 127 | double value; |
| 128 | try { |
| 129 | value = Double.parseDouble(annotated.annotations().value(key)); |
| 130 | } catch (NumberFormatException e) { |
| 131 | value = 1.0; |
| 132 | } |
| 133 | return value; |
| 134 | } |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 135 | } |