Thomas Vachuska

Fixing an issue in basic device config where config always overrode the type to switch.

Change-Id: I0c48e3d9b41fd60f0429d6a2c989a9f5e6e12f40
...@@ -321,7 +321,12 @@ public abstract class Config<S> { ...@@ -321,7 +321,12 @@ public abstract class Config<S> {
321 * @return property value or default value 321 * @return property value or default value
322 */ 322 */
323 protected <E extends Enum<E>> E get(String name, E defaultValue, Class<E> enumClass) { 323 protected <E extends Enum<E>> E get(String name, E defaultValue, Class<E> enumClass) {
324 - return Enum.valueOf(enumClass, object.path(name).asText(defaultValue.toString())); 324 + if (defaultValue != null) {
325 + Enum.valueOf(enumClass, object.path(name).asText(defaultValue.toString()));
326 + }
327 +
328 + JsonNode node = object.get(name);
329 + return node == null ? null : Enum.valueOf(enumClass, node.asText());
325 } 330 }
326 331
327 /** 332 /**
......
...@@ -45,7 +45,7 @@ public final class BasicDeviceConfig extends BasicElementConfig<DeviceId> { ...@@ -45,7 +45,7 @@ public final class BasicDeviceConfig extends BasicElementConfig<DeviceId> {
45 * @return device type override 45 * @return device type override
46 */ 46 */
47 public Device.Type type() { 47 public Device.Type type() {
48 - return get(TYPE, Device.Type.SWITCH, Device.Type.class); 48 + return get(TYPE, null, Device.Type.class);
49 } 49 }
50 50
51 /** 51 /**
......