diff --git a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/BasicInfo.java b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/BasicInfo.java index 4f3a3cb0f6fe7..f5952484f25e0 100644 --- a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/BasicInfo.java +++ b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/BasicInfo.java @@ -14,7 +14,6 @@ import java.util.HashMap; import java.util.Map; -import java.util.Objects; import org.eclipse.jdt.annotation.NonNullByDefault; import org.slf4j.Logger; @@ -43,9 +42,9 @@ public static BasicInfo parse(String response) { Map responseMap = InfoParser.parse(response); BasicInfo info = new BasicInfo(); - info.mac = Objects.requireNonNullElse(responseMap.get("mac"), ""); - info.ret = Objects.requireNonNullElse(responseMap.get("ret"), ""); - info.ssid = Objects.requireNonNullElse(responseMap.get("ssid"), ""); + info.mac = responseMap.getOrDefault("mac", ""); + info.ret = responseMap.getOrDefault("ret", ""); + info.ssid = responseMap.getOrDefault("ssid", ""); return info; } diff --git a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/ControlInfo.java b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/ControlInfo.java index 43b02a9a0dad3..81734c5634afb 100644 --- a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/ControlInfo.java +++ b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/ControlInfo.java @@ -60,7 +60,7 @@ public static ControlInfo parse(String response) { Map responseMap = InfoParser.parse(response); ControlInfo info = new ControlInfo(); - info.ret = Objects.requireNonNull(Optional.ofNullable(responseMap.get("ret")).orElse("")); + info.ret = responseMap.getOrDefault("ret", ""); info.power = "1".equals(responseMap.get("pow")); info.mode = Objects.requireNonNull(Optional.ofNullable(responseMap.get("mode")) .flatMap(value -> InfoParser.parseInt(value)).map(value -> Mode.fromValue(value)).orElse(Mode.AUTO)); @@ -69,8 +69,7 @@ public static ControlInfo parse(String response) { info.autoModeValue = info.mode.getValue(); info.mode = Mode.AUTO; } - info.temp = Objects.requireNonNull( - Optional.ofNullable(responseMap.get("stemp")).flatMap(value -> InfoParser.parseDouble(value))); + info.temp = Optional.ofNullable(responseMap.get("stemp")).flatMap(value -> InfoParser.parseDouble(value)); info.fanSpeed = Objects.requireNonNull(Optional.ofNullable(responseMap.get("f_rate")) .map(value -> FanSpeed.fromValue(value)).orElse(FanSpeed.AUTO)); // determine if device has combined direction (f_dir) or separated directions (f_dir_ud/f_dir_lr) diff --git a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/airbase/AirbaseBasicInfo.java b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/airbase/AirbaseBasicInfo.java index 42f21a8c66dab..361e0b56538c9 100644 --- a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/airbase/AirbaseBasicInfo.java +++ b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/airbase/AirbaseBasicInfo.java @@ -14,7 +14,6 @@ import java.util.HashMap; import java.util.Map; -import java.util.Objects; import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.binding.daikin.internal.api.InfoParser; @@ -44,9 +43,9 @@ public static AirbaseBasicInfo parse(String response) { Map responseMap = InfoParser.parse(response); AirbaseBasicInfo info = new AirbaseBasicInfo(); - info.mac = Objects.requireNonNullElse(responseMap.get("mac"), ""); - info.ret = Objects.requireNonNullElse(responseMap.get("ret"), ""); - info.ssid = Objects.requireNonNullElse(responseMap.get("ssid"), ""); + info.mac = responseMap.getOrDefault("mac", ""); + info.ret = responseMap.getOrDefault("ret", ""); + info.ssid = responseMap.getOrDefault("ssid", ""); return info; } diff --git a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/airbase/AirbaseControlInfo.java b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/airbase/AirbaseControlInfo.java index ffd595cba0a1a..aece069cb6aaa 100644 --- a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/airbase/AirbaseControlInfo.java +++ b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/airbase/AirbaseControlInfo.java @@ -55,7 +55,7 @@ public static AirbaseControlInfo parse(String response) { Map responseMap = InfoParser.parse(response); AirbaseControlInfo info = new AirbaseControlInfo(); - info.ret = Objects.requireNonNullElse(responseMap.get("ret"), ""); + info.ret = responseMap.getOrDefault("ret", ""); info.power = "1".equals(responseMap.get("pow")); info.mode = Objects.requireNonNull( Optional.ofNullable(responseMap.get("mode")).flatMap(value -> InfoParser.parseInt(value)) diff --git a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/airbase/AirbaseModelInfo.java b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/airbase/AirbaseModelInfo.java index 8a3af7bc7ad94..615fa0913dd0f 100644 --- a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/airbase/AirbaseModelInfo.java +++ b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/airbase/AirbaseModelInfo.java @@ -14,7 +14,6 @@ import java.util.EnumSet; import java.util.Map; -import java.util.Objects; import java.util.Optional; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -49,7 +48,7 @@ public static AirbaseModelInfo parse(String response) { Map responseMap = InfoParser.parse(response); AirbaseModelInfo info = new AirbaseModelInfo(); - info.ret = Objects.requireNonNullElse(responseMap.get("ret"), ""); + info.ret = responseMap.getOrDefault("ret", ""); info.zonespresent = Optional.ofNullable(responseMap.get("en_zone")).flatMap(value -> InfoParser.parseInt(value)) .orElse(0); info.commonzone = Optional.ofNullable(responseMap.get("en_common_zone")) diff --git a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/airbase/AirbaseZoneInfo.java b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/airbase/AirbaseZoneInfo.java index b63af08a771b1..d713db6c1ff69 100644 --- a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/airbase/AirbaseZoneInfo.java +++ b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/airbase/AirbaseZoneInfo.java @@ -14,7 +14,6 @@ import java.util.LinkedHashMap; import java.util.Map; -import java.util.Objects; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -46,8 +45,8 @@ public static AirbaseZoneInfo parse(String response) { Map responseMap = InfoParser.parse(response); AirbaseZoneInfo info = new AirbaseZoneInfo(); - info.zonenames = Objects.requireNonNullElse(responseMap.get("zone_name"), ""); - String zoneinfo = Objects.requireNonNullElse(responseMap.get("zone_onoff"), ""); + info.zonenames = responseMap.getOrDefault("zone_name", ""); + String zoneinfo = responseMap.getOrDefault("zone_onoff", ""); String[] zones = zoneinfo.split(";"); diff --git a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/discovery/DaikinACUnitDiscoveryService.java b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/discovery/DaikinACUnitDiscoveryService.java index 1be4f1b751781..67347b5fedf5b 100644 --- a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/discovery/DaikinACUnitDiscoveryService.java +++ b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/discovery/DaikinACUnitDiscoveryService.java @@ -21,7 +21,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.concurrent.ScheduledFuture; @@ -135,7 +134,7 @@ private boolean receivePacketAndDiscover(DatagramSocket socket) { Map parsedData = InfoParser.parse(data); Boolean secure = "1".equals(parsedData.get("en_secure")); String thingId = Objects.requireNonNullElse(parsedData.get("ssid"), host.replace(".", "_")); - String mac = Optional.ofNullable(parsedData.get("mac")).orElse(""); + String mac = parsedData.getOrDefault("mac", ""); String uuid = mac.isEmpty() ? UUID.randomUUID().toString() : UUID.nameUUIDFromBytes(mac.getBytes()).toString();