Avoid star imports and add missing braces (#10521)

Fixes the following SAT findings:

* AvoidStarImportCheck (125)
* NeedBracesCheck (39)

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born
2021-04-15 16:12:05 +02:00
committed by GitHub
parent e24d43aecb
commit 0c36650179
110 changed files with 793 additions and 217 deletions

View File

@@ -15,7 +15,11 @@ package org.openhab.binding.unifiedremote.internal;
import static org.openhab.binding.unifiedremote.internal.UnifiedRemoteBindingConstants.*;
import java.io.IOException;
import java.net.*;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.text.ParseException;
import java.util.Arrays;
import java.util.HashMap;
@@ -107,8 +111,9 @@ public class UnifiedRemoteDiscoveryService extends AbstractDiscoveryService {
String host = receivePacket.getAddress().getHostAddress();
String reply = new String(receivePacket.getData()).replaceAll("[\\p{C}]", NON_PRINTABLE_CHARTS_REPLACEMENT)
.replaceAll("[^\\x00-\\x7F]", NON_PRINTABLE_CHARTS_REPLACEMENT);
if (!reply.startsWith(DISCOVERY_RESPONSE_PREFIX))
if (!reply.startsWith(DISCOVERY_RESPONSE_PREFIX)) {
throw new ParseException("Bad discovery response prefix", 0);
}
String[] parts = Arrays
.stream(reply.replace(DISCOVERY_RESPONSE_PREFIX, "").split(NON_PRINTABLE_CHARTS_REPLACEMENT))
.filter((String e) -> e.length() != 0).toArray(String[]::new);

View File

@@ -12,8 +12,7 @@
*/
package org.openhab.binding.unifiedremote.internal;
import static org.openhab.binding.unifiedremote.internal.UnifiedRemoteBindingConstants.MOUSE_CHANNEL;
import static org.openhab.binding.unifiedremote.internal.UnifiedRemoteBindingConstants.SEND_KEY_CHANNEL;
import static org.openhab.binding.unifiedremote.internal.UnifiedRemoteBindingConstants.*;
import java.net.ConnectException;
import java.net.NoRouteToHostException;
@@ -54,8 +53,9 @@ public class UnifiedRemoteHandler extends BaseThingHandler {
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
String channelId = channelUID.getId();
if (!isLinked(channelId))
if (!isLinked(channelId)) {
return;
}
String stringCommand = command.toFullString();
UnifiedRemoteConnection urConnection = connection;
try {
@@ -107,8 +107,9 @@ public class UnifiedRemoteHandler extends BaseThingHandler {
connectionCheckerSchedule = scheduler.scheduleWithFixedDelay(() -> {
try {
UnifiedRemoteConnection urConnection = connection;
if (urConnection == null)
if (urConnection == null) {
return;
}
ThingStatus status = thing.getStatus();
if ((status == ThingStatus.OFFLINE || status == ThingStatus.UNKNOWN) && connection != null) {
urConnection.authenticate();