diff --git a/bundles/org.openhab.binding.keba/src/main/java/org/openhab/binding/keba/internal/KebaBindingConstants.java b/bundles/org.openhab.binding.keba/src/main/java/org/openhab/binding/keba/internal/KebaBindingConstants.java index 18841e88a..417225b93 100644 --- a/bundles/org.openhab.binding.keba/src/main/java/org/openhab/binding/keba/internal/KebaBindingConstants.java +++ b/bundles/org.openhab.binding.keba/src/main/java/org/openhab/binding/keba/internal/KebaBindingConstants.java @@ -15,7 +15,6 @@ package org.openhab.binding.keba.internal; import java.util.ArrayList; import java.util.List; -import org.apache.commons.lang3.ArrayUtils; import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.thing.ThingTypeUID; @@ -87,8 +86,7 @@ public class KebaBindingConstants { private final List things = new ArrayList<>(); KebaSeries(char... e) { - Character[] cArray = ArrayUtils.toObject(e); - for (char c : cArray) { + for (char c : e) { things.add(c); } } diff --git a/bundles/org.openhab.binding.keba/src/main/java/org/openhab/binding/keba/internal/handler/KeContactHandler.java b/bundles/org.openhab.binding.keba/src/main/java/org/openhab/binding/keba/internal/handler/KeContactHandler.java index a16abfd30..49bb33352 100644 --- a/bundles/org.openhab.binding.keba/src/main/java/org/openhab/binding/keba/internal/handler/KeContactHandler.java +++ b/bundles/org.openhab.binding.keba/src/main/java/org/openhab/binding/keba/internal/handler/KeContactHandler.java @@ -22,6 +22,7 @@ import java.net.SocketAddress; import java.nio.ByteBuffer; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; @@ -32,7 +33,6 @@ import javax.measure.quantity.Energy; import javax.measure.quantity.Power; import javax.measure.quantity.Time; -import org.apache.commons.lang3.StringUtils; import org.openhab.binding.keba.internal.KebaBindingConstants.KebaSeries; import org.openhab.binding.keba.internal.KebaBindingConstants.KebaType; import org.openhab.core.cache.ExpiringCacheMap; @@ -51,6 +51,7 @@ import org.openhab.core.thing.binding.BaseThingHandler; import org.openhab.core.types.Command; import org.openhab.core.types.RefreshType; import org.openhab.core.types.State; +import org.openhab.core.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -237,7 +238,7 @@ public class KeContactHandler extends BaseThingHandler { } String response = new String(byteBuffer.array(), 0, byteBuffer.limit()); - response = StringUtils.chomp(response); + response = Objects.requireNonNull(StringUtils.chomp(response)); if (response.contains("TCH-OK")) { // ignore confirmation messages which are not JSON @@ -529,7 +530,7 @@ public class KeContactHandler extends BaseThingHandler { switch (channelUID.getId()) { case CHANNEL_MAX_PRESET_CURRENT: { if (command instanceof QuantityType quantityCommand) { - QuantityType value = quantityCommand.toUnit("mA"); + QuantityType value = Objects.requireNonNull(quantityCommand.toUnit("mA")); transceiver.send("curr " + Math.min(Math.max(6000, value.intValue()), maxSystemCurrent), this); } @@ -548,7 +549,7 @@ public class KeContactHandler extends BaseThingHandler { } else if (command == OnOffType.OFF) { newValue = 6000; } else if (command instanceof QuantityType quantityCommand) { - QuantityType value = quantityCommand.toUnit("%"); + QuantityType value = Objects.requireNonNull(quantityCommand.toUnit("%")); newValue = Math.round(6000 + (maxSystemCurrent - 6000) * value.doubleValue() / 100.0); } else { return; @@ -595,7 +596,7 @@ public class KeContactHandler extends BaseThingHandler { } case CHANNEL_SETENERGY: { if (command instanceof QuantityType quantityCommand) { - QuantityType value = quantityCommand.toUnit(Units.WATT_HOUR); + QuantityType value = Objects.requireNonNull(quantityCommand.toUnit(Units.WATT_HOUR)); transceiver.send( "setenergy " + Math.min(Math.max(0, Math.round(value.doubleValue() * 10.0)), 999999999), this);