aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/core/api/src/main/java/org/onosproject/net/AnnotationKeys.java
blob: 38b599de5dbcccc8dad456ad4a8a5cd036c1541c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
 * Copyright 2014-2015 Open Networking Laboratory
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.onosproject.net;

/**
 * Collection of keys for annotation.
 * <p>
 * Number of the annotation keys have been deprecated as the use of annotations
 * is being phased out and instead network configuration subsystem is being
 * phased-in for majority of model meta-data.
 * </p>
 */
public final class AnnotationKeys {

    // Prohibit instantiation
    private AnnotationKeys() {
    }

    /**
     * Annotation key for instance name.
     *
     * @deprecated since Cardinal
     */
    @Deprecated
    public static final String NAME = "name";

    /**
     * Annotation key for instance type (e.g. host type).
     *
     * @deprecated since Cardinal
     */
    @Deprecated
    public static final String TYPE = "type";

    /**
     * Annotation key for latitude (e.g. latitude of device).
     *
     * @deprecated since Cardinal
     */
    @Deprecated
    public static final String LATITUDE = "latitude";

    /**
     * Annotation key for longitute (e.g. longitude of device).
     *
     * @deprecated since Cardinal
     */
    @Deprecated
    public static final String LONGITUDE = "longitude";

    /**
     * Annotation key for southbound protocol.
     */
    public static final String PROTOCOL = "protocol";

    /**
     * Annotation key for the device driver name.
     *
     * @deprecated since Cardinal
     */
    @Deprecated
    public static final String DRIVER = "driver";

    /**
     * Annotation key for durable links.
     */
    public static final String DURABLE = "durable";

    /**
     * Annotation key for link metric; used by
     * {@link org.onosproject.net.topology.MetricLinkWeight} function.
     */
    public static final String METRIC = "metric";

    /**
     * Annotation key for latency.
     *
     * @deprecated since Cardinal
     */
    @Deprecated
    public static final String LATENCY = "latency";

    /**
     * Annotation key for bandwidth.
     * The value for this key is interpreted as Mbps.
     *
     * @deprecated since Cardinal
     */
    @Deprecated
    public static final String BANDWIDTH = "bandwidth";

    /**
     * Annotation key for the number of optical waves.
     */
    public static final String OPTICAL_WAVES = "optical.waves";

    /**
     * Annotation key for the port name.
     */
    public static final String PORT_NAME = "portName";

    /**
     * Annotation key for the port mac.
     */
    public static final String PORT_MAC = "portMac";

    /**
     * Annotation key for the router ID.
     */
    public static final String ROUTER_ID = "routerId";

    /**
     * Annotation key for the static lambda.
     */
    public static final String STATIC_LAMBDA = "staticLambda";

    /**
     * Annotation key for the static port.
     */
    public static final String STATIC_PORT = "staticPort";

    /**
     * Annotation key for device location.
     */
    public static final String RACK_ADDRESS = "rackAddress";

    /**
     * Annotation key for device owner.
     */
    public static final String OWNER = "owner";

    /**
     * Annotation key for the channel id.
     */
    public static final String CHANNEL_ID = "channelId";

    /**
     * Annotation key for the management address.
     */
    public static final String MANAGEMENT_ADDRESS = "managementAddress";

    /**
     * Returns the value annotated object for the specified annotation key.
     * The annotated value is expected to be String that can be parsed as double.
     * If parsing fails, the returned value will be 1.0.
     *
     * @param annotated annotated object whose annotated value is obtained
     * @param key       key of annotation
     * @return double value of annotated object for the specified key
     */
    public static double getAnnotatedValue(Annotated annotated, String key) {
        double value;
        try {
            value = Double.parseDouble(annotated.annotations().value(key));
        } catch (NumberFormatException e) {
            value = 1.0;
        }
        return value;
    }
}