blob: 3871b3f43c9b5d4a7d89d9fe8c4c5f7de028be5b [file] [log] [blame]
Sho SHIMIZUfe129db2014-11-11 14:24:51 -08001/*
2 * Copyright 2014 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.onlab.onos.net;
17
18/**
19 * Collection of keys for annotation.
20 * Definitions of annotation keys needs to be here to avoid scattering.
21 */
22public final class AnnotationKeys {
23
24 // Prohibit instantiation
25 private AnnotationKeys() {}
26
27 /**
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080028 * Annotation key for instance name.
29 */
30 public static final String NAME = "name";
31
32 /**
33 * Annotation key for instance type (e.g. host type).
34 */
35 public static final String TYPE = "type";
36
37 /**
38 * Annotation key for latitude (e.g. latitude of device).
39 */
40 public static final String LATITUDE = "latitude";
41
42 /**
43 * Annotation key for longitute (e.g. longitude of device).
44 */
45 public static final String LONGITUDE = "longitude";
46
47 /**
48 * Annotation key for southbound protocol.
49 */
50 public static final String PROTOCOL = "protocol";
51
52 /**
Thomas Vachuska57126fe2014-11-11 17:13:24 -080053 * Annotation key for durable links.
54 */
55 public static final String DURABLE = "durable";
56
57 /**
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080058 * Annotation key for latency.
59 */
60 public static final String LATENCY = "latency";
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -080061
62 /**
Toshio Koide4b6562b2014-11-13 17:20:47 -080063 * Annotation key for bandwidth.
64 */
65 public static final String BANDWIDTH = "bandwidth";
66
67 /**
68 * Annotation key for the number of optical waves.
69 */
70 public static final String OPTICAL_WAVES = "optical.waves";
71
72 /**
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -080073 * Returns the value annotated object for the specified annotation key.
74 * The annotated value is expected to be String that can be parsed as double.
75 * If parsing fails, the returned value will be 1.0.
76 *
77 * @param annotated annotated object whose annotated value is obtained
78 * @param key key of annotation
79 * @return double value of annotated object for the specified key
80 */
81 public static double getAnnotatedValue(Annotated annotated, String key) {
82 double value;
83 try {
84 value = Double.parseDouble(annotated.annotations().value(key));
85 } catch (NumberFormatException e) {
86 value = 1.0;
87 }
88 return value;
89 }
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080090}