Java 17 features (H-M) (#15520)
- 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:
@@ -12,7 +12,6 @@
|
||||
*/
|
||||
package org.openhab.binding.lgwebos.internal;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
@@ -31,7 +30,7 @@ public class LGWebOSBindingConstants {
|
||||
|
||||
public static final ThingTypeUID THING_TYPE_WEBOSTV = new ThingTypeUID(BINDING_ID, "WebOSTV");
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_WEBOSTV);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_WEBOSTV);
|
||||
|
||||
public static final ServiceType UPNP_SERVICE_TYPE = new ServiceType("lge-com", "webos-second-screen", 1);
|
||||
|
||||
|
||||
@@ -64,9 +64,11 @@ public class PowerControlPower extends BaseChannelHandler<CommandConfirmation> {
|
||||
case DISCONNECTED:
|
||||
String macAddress = configProvider.getMacAddress();
|
||||
if (macAddress.isEmpty()) {
|
||||
logger.debug("Received ON - Turning TV on via API is not supported by LG WebOS TVs. "
|
||||
+ "You may succeed using wake on lan (WOL). "
|
||||
+ "Please set the macAddress config value in Thing configuration to enable this.");
|
||||
logger.debug("""
|
||||
Received ON - Turning TV on via API is not supported by LG WebOS TVs. \
|
||||
You may succeed using wake on lan (WOL). \
|
||||
Please set the macAddress config value in Thing configuration to enable this.\
|
||||
""");
|
||||
handler.postUpdate(channelId, OnOffType.OFF);
|
||||
} else {
|
||||
for (int i = 0; i < WOL_PACKET_RETRY_COUNT; i++) {
|
||||
|
||||
@@ -49,12 +49,12 @@ public class VolumeControlVolume extends BaseChannelHandler<Float> {
|
||||
handler.getSocket().getVolume(createResponseListener(channelId, handler));
|
||||
return;
|
||||
}
|
||||
if (command instanceof PercentType) {
|
||||
percent = (PercentType) command;
|
||||
} else if (command instanceof DecimalType) {
|
||||
percent = new PercentType(((DecimalType) command).toBigDecimal());
|
||||
} else if (command instanceof StringType) {
|
||||
percent = new PercentType(((StringType) command).toString());
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
percent = percentCommand;
|
||||
} else if (command instanceof DecimalType decimalCommand) {
|
||||
percent = new PercentType(decimalCommand.toBigDecimal());
|
||||
} else if (command instanceof StringType stringCommand) {
|
||||
percent = new PercentType(stringCommand.toString());
|
||||
} else {
|
||||
percent = null;
|
||||
}
|
||||
|
||||
@@ -48,9 +48,9 @@ public class WakeOnLanUtility {
|
||||
static {
|
||||
String os = System.getProperty("os.name").toLowerCase();
|
||||
LOGGER.debug("os: {}", os);
|
||||
if ((os.indexOf("win") >= 0)) {
|
||||
if ((os.contains("win"))) {
|
||||
COMMAND = "arp -a %s";
|
||||
} else if ((os.indexOf("mac") >= 0)) {
|
||||
} else if ((os.contains("mac"))) {
|
||||
COMMAND = "arp %s";
|
||||
} else { // linux
|
||||
if (checkIfLinuxCommandExists("arp")) {
|
||||
|
||||
@@ -115,7 +115,7 @@ public class LGWebOSActions implements ThingActions {
|
||||
private List<AppInfo> getAppInfos() {
|
||||
LGWebOSHandler lgWebOSHandler = getLGWebOSHandler();
|
||||
|
||||
if (!this.getConnectedSocket().isPresent()) {
|
||||
if (this.getConnectedSocket().isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
@@ -65,8 +65,8 @@ public class LGWebOSCommandExtension extends AbstractConsoleCommandExtension imp
|
||||
LGWebOSHandler handler = null;
|
||||
if (thing != null) {
|
||||
thingHandler = thing.getHandler();
|
||||
if (thingHandler instanceof LGWebOSHandler) {
|
||||
handler = (LGWebOSHandler) thingHandler;
|
||||
if (thingHandler instanceof LGWebOSHandler webOSHandler) {
|
||||
handler = webOSHandler;
|
||||
}
|
||||
}
|
||||
if (thing == null) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -373,7 +374,7 @@ public class LGWebOSHandler extends BaseThingHandler
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(LGWebOSActions.class);
|
||||
return Set.of(LGWebOSActions.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user