Java 17 features (T-Z) (#15576)
- add missing @override - Java style array syntax - remove redundant modifiers - always move String constants to left side in comparisons - simplify lambda expressions and return statements - use replace instead of replaceAll w/o regex - instanceof matching and multiline strings - remove null check before instanceof Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
@@ -27,7 +27,7 @@ public class YIOremoteBindingConstants {
|
||||
public static final String BINDING_ID = "yioremote";
|
||||
|
||||
// List of all used global variables
|
||||
public static enum YioRemoteDockHandleStatus {
|
||||
public enum YioRemoteDockHandleStatus {
|
||||
UNINITIALIZED_STATE,
|
||||
AUTHENTICATION_PROCESS,
|
||||
AUTHENTICATION_FAILED,
|
||||
@@ -37,15 +37,15 @@ public class YIOremoteBindingConstants {
|
||||
CONNECTION_FAILED,
|
||||
CONNECTION_ESTABLISHED,
|
||||
COMMUNICATION_ERROR,
|
||||
RECONNECTION_PROCESS;
|
||||
RECONNECTION_PROCESS
|
||||
}
|
||||
|
||||
public static enum YioRemoteMessages {
|
||||
public enum YioRemoteMessages {
|
||||
IR_SEND,
|
||||
AUTHENTICATE_MESSAGE,
|
||||
HEARTBEAT_MESSAGE,
|
||||
IR_RECEIVER_ON,
|
||||
IR_RECEIVER_OFF;
|
||||
IR_RECEIVER_OFF
|
||||
}
|
||||
|
||||
// List of all Thing Type UIDs
|
||||
|
||||
@@ -17,7 +17,7 @@ import static org.openhab.binding.yioremote.internal.YIOremoteBindingConstants.*
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -177,20 +177,20 @@ public class YIOremoteDockHandler extends BaseThingHandler {
|
||||
boolean success = false;
|
||||
|
||||
if (message.has("type")) {
|
||||
if (message.get("type").toString().equalsIgnoreCase("\"auth_required\"")) {
|
||||
if ("\"auth_required\"".equalsIgnoreCase(message.get("type").toString())) {
|
||||
success = true;
|
||||
receivedStatus = "Authentication required";
|
||||
} else if (message.get("type").toString().equalsIgnoreCase("\"auth_ok\"")) {
|
||||
} else if ("\"auth_ok\"".equalsIgnoreCase(message.get("type").toString())) {
|
||||
authenticationOk = true;
|
||||
success = true;
|
||||
receivedStatus = "Authentication ok";
|
||||
} else if (message.get("type").toString().equalsIgnoreCase("\"dock\"") && message.has("message")) {
|
||||
if (message.get("message").toString().equalsIgnoreCase("\"pong\"")) {
|
||||
} else if ("\"dock\"".equalsIgnoreCase(message.get("type").toString()) && message.has("message")) {
|
||||
if ("\"pong\"".equalsIgnoreCase(message.get("message").toString())) {
|
||||
heartBeat = true;
|
||||
success = true;
|
||||
receivedStatus = "Heart beat received";
|
||||
} else if (message.get("message").toString().equalsIgnoreCase("\"ir_send\"")) {
|
||||
if (message.get("success").toString().equalsIgnoreCase("true")) {
|
||||
} else if ("\"ir_send\"".equalsIgnoreCase(message.get("message").toString())) {
|
||||
if ("true".equalsIgnoreCase(message.get("success").toString())) {
|
||||
receivedStatus = "Send IR Code successfully";
|
||||
success = true;
|
||||
} else {
|
||||
@@ -203,7 +203,7 @@ public class YIOremoteDockHandler extends BaseThingHandler {
|
||||
heartBeat = false;
|
||||
success = false;
|
||||
}
|
||||
} else if (message.get("command").toString().equalsIgnoreCase("\"ir_receive\"")) {
|
||||
} else if ("\"ir_receive\"".equalsIgnoreCase(message.get("command").toString())) {
|
||||
receivedStatus = message.get("code").toString().replace("\"", "");
|
||||
if (receivedStatus.matches("[0-9]?[0-9][;]0[xX][0-9a-fA-F]+[;][0-9]+[;][0-9]")) {
|
||||
irCodeReceivedHandler.setCode(message.get("code").toString().replace("\"", ""));
|
||||
@@ -241,8 +241,7 @@ public class YIOremoteDockHandler extends BaseThingHandler {
|
||||
}
|
||||
return result;
|
||||
} catch (IllegalArgumentException e) {
|
||||
JsonObject result = new JsonObject();
|
||||
return result;
|
||||
return new JsonObject();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +252,7 @@ public class YIOremoteDockHandler extends BaseThingHandler {
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(YIOremoteDockActions.class);
|
||||
return Set.of(YIOremoteDockActions.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,6 @@ package org.openhab.binding.yioremote.internal;
|
||||
|
||||
import static org.openhab.binding.yioremote.internal.YIOremoteBindingConstants.THING_TYPE_YIOREMOTEDOCK;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
@@ -36,7 +35,7 @@ import org.osgi.service.component.annotations.Component;
|
||||
@Component(configurationPid = "binding.yioremote", service = ThingHandlerFactory.class)
|
||||
public class YIOremoteHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_YIOREMOTEDOCK);
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_YIOREMOTEDOCK);
|
||||
|
||||
@Override
|
||||
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
|
||||
|
||||
Reference in New Issue
Block a user