Refactor: move method to get annotated double value
- Move to AnnotationKeys to remove code duplication
Change-Id: Icf8b4322fc88e43ab531402d0e403a38d186f48e
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 45151ef..7b1411a 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
@@ -26,6 +26,7 @@
import java.util.Objects;
import static org.onlab.onos.net.AnnotationKeys.LATENCY;
+import static org.onlab.onos.net.AnnotationKeys.getAnnotatedValue;
/**
* Constraint that evaluates the latency through a path.
@@ -48,16 +49,7 @@
@Override
public double cost(Link link, LinkResourceService resourceService) {
- String value = link.annotations().value(LATENCY);
-
- double latencyInMicroSec;
- try {
- latencyInMicroSec = Double.parseDouble(value);
- } catch (NumberFormatException e) {
- latencyInMicroSec = 1.0;
- }
-
- return latencyInMicroSec;
+ return getAnnotatedValue(link, LATENCY);
}
@Override