default value for driver property
Change-Id: I13963776c8ec1ad270be2cd73181e91167e37ead
diff --git a/core/api/src/main/java/org/onosproject/net/driver/Driver.java b/core/api/src/main/java/org/onosproject/net/driver/Driver.java
index 7c16dfc..a09d1f7 100644
--- a/core/api/src/main/java/org/onosproject/net/driver/Driver.java
+++ b/core/api/src/main/java/org/onosproject/net/driver/Driver.java
@@ -19,6 +19,7 @@
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
/**
@@ -142,6 +143,20 @@
String getProperty(String name);
/**
+ * Gets the value of given property name.
+ * If the driver does not define the property, a BFS will be performed to search its ancestors.
+ *
+ * @param name property name
+ * @param defaultValue to use if the property is not defined in this driver nor in any of its ancestors
+ * @return the value of the property,
+ * or {@code defaultValue} if the property is not defined in this driver nor in any of its ancestors
+ * @return
+ */
+ default String getProperty(String name, String defaultValue) {
+ return Optional.ofNullable(getProperty(name)).orElse(defaultValue);
+ }
+
+ /**
* Merges the specified driver behaviours and properties into this one,
* giving preference to the other driver when dealing with conflicts.
*