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:
Holger Friedrich
2023-09-08 14:36:59 +02:00
committed by GitHub
parent 3751fd0646
commit edaf17b345
519 changed files with 2703 additions and 2660 deletions

View File

@@ -12,7 +12,6 @@
*/
package org.openhab.binding.lghombot.internal;
import java.util.Collections;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -32,7 +31,7 @@ public final class LGHomBotBindingConstants {
// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_LGHOMBOT = new ThingTypeUID(BINDING_ID, "LGHomBot");
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_LGHOMBOT);
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_LGHOMBOT);
// List of all Channel ids
static final String CHANNEL_STATE = "state";

View File

@@ -14,7 +14,6 @@ package org.openhab.binding.lghombot.internal;
import static org.openhab.binding.lghombot.internal.LGHomBotBindingConstants.THING_TYPE_LGHOMBOT;
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.lghombot", service = ThingHandlerFactory.class)
public class LGHomBotHandlerFactory extends BaseThingHandlerFactory {
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_LGHOMBOT);
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_LGHOMBOT);
@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {

View File

@@ -236,12 +236,12 @@ public class LGHomBotDiscovery extends AbstractDiscoveryService {
if (idx > 0) {
String name = msg.substring(0, idx);
if (name.equalsIgnoreCase("JSON_NICKNAME")) {
nickName = msg.substring(idx + 1).trim().replaceAll("\"", "");
} else if (name.equalsIgnoreCase("JSON_VERSION")) {
fwVersion = msg.substring(idx + 1).trim().replaceAll("\"", "");
} else if (name.equalsIgnoreCase("LGSRV_VERSION")) {
srvVersion = msg.substring(idx + 1).trim().replaceAll("\"", "");
if ("JSON_NICKNAME".equalsIgnoreCase(name)) {
nickName = msg.substring(idx + 1).trim().replace("\"", "");
} else if ("JSON_VERSION".equalsIgnoreCase(name)) {
fwVersion = msg.substring(idx + 1).trim().replace("\"", "");
} else if ("LGSRV_VERSION".equalsIgnoreCase(name)) {
srvVersion = msg.substring(idx + 1).trim().replace("\"", "");
}
}