Skip to content

Commit 3ed22b4

Browse files
authored
[keba] Remove org.apache.commons (openhab#14409)
Signed-off-by: Leo Siepel <[email protected]>
1 parent 38df4ac commit 3ed22b4

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

bundles/org.openhab.binding.keba/src/main/java/org/openhab/binding/keba/internal/KebaBindingConstants.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import java.util.ArrayList;
1616
import java.util.List;
1717

18-
import org.apache.commons.lang3.ArrayUtils;
1918
import org.eclipse.jdt.annotation.NonNullByDefault;
2019
import org.openhab.core.thing.ThingTypeUID;
2120

@@ -87,8 +86,7 @@ public enum KebaSeries {
8786
private final List<Character> things = new ArrayList<>();
8887

8988
KebaSeries(char... e) {
90-
Character[] cArray = ArrayUtils.toObject(e);
91-
for (char c : cArray) {
89+
for (char c : e) {
9290
things.add(c);
9391
}
9492
}

bundles/org.openhab.binding.keba/src/main/java/org/openhab/binding/keba/internal/handler/KeContactHandler.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.nio.ByteBuffer;
2323
import java.util.Map;
2424
import java.util.Map.Entry;
25+
import java.util.Objects;
2526
import java.util.concurrent.ScheduledFuture;
2627
import java.util.concurrent.TimeUnit;
2728

@@ -32,7 +33,6 @@
3233
import javax.measure.quantity.Power;
3334
import javax.measure.quantity.Time;
3435

35-
import org.apache.commons.lang3.StringUtils;
3636
import org.openhab.binding.keba.internal.KebaBindingConstants.KebaSeries;
3737
import org.openhab.binding.keba.internal.KebaBindingConstants.KebaType;
3838
import org.openhab.core.cache.ExpiringCacheMap;
@@ -51,6 +51,7 @@
5151
import org.openhab.core.types.Command;
5252
import org.openhab.core.types.RefreshType;
5353
import org.openhab.core.types.State;
54+
import org.openhab.core.util.StringUtils;
5455
import org.slf4j.Logger;
5556
import org.slf4j.LoggerFactory;
5657

@@ -237,7 +238,7 @@ protected void onData(ByteBuffer byteBuffer) {
237238
}
238239

239240
String response = new String(byteBuffer.array(), 0, byteBuffer.limit());
240-
response = StringUtils.chomp(response);
241+
response = Objects.requireNonNull(StringUtils.chomp(response));
241242

242243
if (response.contains("TCH-OK")) {
243244
// ignore confirmation messages which are not JSON
@@ -529,7 +530,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
529530
switch (channelUID.getId()) {
530531
case CHANNEL_MAX_PRESET_CURRENT: {
531532
if (command instanceof QuantityType<?> quantityCommand) {
532-
QuantityType<?> value = quantityCommand.toUnit("mA");
533+
QuantityType<?> value = Objects.requireNonNull(quantityCommand.toUnit("mA"));
533534

534535
transceiver.send("curr " + Math.min(Math.max(6000, value.intValue()), maxSystemCurrent), this);
535536
}
@@ -548,7 +549,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
548549
} else if (command == OnOffType.OFF) {
549550
newValue = 6000;
550551
} else if (command instanceof QuantityType<?> quantityCommand) {
551-
QuantityType<?> value = quantityCommand.toUnit("%");
552+
QuantityType<?> value = Objects.requireNonNull(quantityCommand.toUnit("%"));
552553
newValue = Math.round(6000 + (maxSystemCurrent - 6000) * value.doubleValue() / 100.0);
553554
} else {
554555
return;
@@ -595,7 +596,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
595596
}
596597
case CHANNEL_SETENERGY: {
597598
if (command instanceof QuantityType<?> quantityCommand) {
598-
QuantityType<?> value = quantityCommand.toUnit(Units.WATT_HOUR);
599+
QuantityType<?> value = Objects.requireNonNull(quantityCommand.toUnit(Units.WATT_HOUR));
599600
transceiver.send(
600601
"setenergy " + Math.min(Math.max(0, Math.round(value.doubleValue() * 10.0)), 999999999),
601602
this);

0 commit comments

Comments
 (0)