Fix for ONOS-5034
Change-Id: I61158511680851be375b93c365fc32c0573e9edc
diff --git a/utils/misc/src/main/java/org/onlab/util/Tools.java b/utils/misc/src/main/java/org/onlab/util/Tools.java
index 60a80c1..25c0213 100644
--- a/utils/misc/src/main/java/org/onlab/util/Tools.java
+++ b/utils/misc/src/main/java/org/onlab/util/Tools.java
@@ -364,6 +364,26 @@
}
/**
+ * Get Long property from the propertyName
+ * Return null if propertyName is not found.
+ *
+ * @param properties properties to be looked up
+ * @param propertyName the name of the property to look up
+ * @return value when the propertyName is defined or return null
+ */
+ public static Long getLongProperty(Dictionary<?, ?> properties,
+ String propertyName) {
+ Long value;
+ try {
+ String s = get(properties, propertyName);
+ value = Strings.isNullOrEmpty(s) ? null : Long.valueOf(s);
+ } catch (NumberFormatException | ClassCastException e) {
+ value = null;
+ }
+ return value;
+ }
+
+ /**
* Returns a function that retries execution on failure.
* @param base base function
* @param exceptionClass type of exception for which to retry