Fixing an issue in basic device config where config always overrode the type to switch.
Change-Id: I0c48e3d9b41fd60f0429d6a2c989a9f5e6e12f40
diff --git a/core/api/src/main/java/org/onosproject/net/config/Config.java b/core/api/src/main/java/org/onosproject/net/config/Config.java
index 4aa3d8d..4dce014 100644
--- a/core/api/src/main/java/org/onosproject/net/config/Config.java
+++ b/core/api/src/main/java/org/onosproject/net/config/Config.java
@@ -321,7 +321,12 @@
* @return property value or default value
*/
protected <E extends Enum<E>> E get(String name, E defaultValue, Class<E> enumClass) {
- return Enum.valueOf(enumClass, object.path(name).asText(defaultValue.toString()));
+ if (defaultValue != null) {
+ Enum.valueOf(enumClass, object.path(name).asText(defaultValue.toString()));
+ }
+
+ JsonNode node = object.get(name);
+ return node == null ? null : Enum.valueOf(enumClass, node.asText());
}
/**