Aggregate definition of annotation key for latency into a single file
Change-Id: Id0b9089ec60e6f144ff42c40d0e1b19b280c4271
diff --git a/core/api/src/main/java/org/onlab/onos/net/AnnotationKeys.java b/core/api/src/main/java/org/onlab/onos/net/AnnotationKeys.java
new file mode 100644
index 0000000..eace91c
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/net/AnnotationKeys.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2014 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.onlab.onos.net;
+
+/**
+ * Collection of keys for annotation.
+ * Definitions of annotation keys needs to be here to avoid scattering.
+ */
+public final class AnnotationKeys {
+
+ // Prohibit instantiation
+ private AnnotationKeys() {}
+
+ /**
+ * Annotation key for latency.
+ */
+ public static final String LATENCY = "latency";
+}
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/constraint/LatencyConstraint.java b/core/api/src/main/java/org/onlab/onos/net/intent/constraint/LatencyConstraint.java
index fcdf330..45151ef 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/constraint/LatencyConstraint.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/constraint/LatencyConstraint.java
@@ -25,14 +25,13 @@
import java.time.temporal.ChronoUnit;
import java.util.Objects;
+import static org.onlab.onos.net.AnnotationKeys.LATENCY;
+
/**
* Constraint that evaluates the latency through a path.
*/
public class LatencyConstraint implements Constraint {
- // TODO: formalize the key for latency all over the codes.
- private static final String LATENCY_KEY = "latency";
-
private final Duration latency;
/**
@@ -49,7 +48,7 @@
@Override
public double cost(Link link, LinkResourceService resourceService) {
- String value = link.annotations().value(LATENCY_KEY);
+ String value = link.annotations().value(LATENCY);
double latencyInMicroSec;
try {