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

@@ -22,7 +22,7 @@ import java.nio.file.StandardWatchEventKinds;
import java.nio.file.WatchKey;
import java.nio.file.WatchService;
import java.time.Duration;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
@@ -59,7 +59,7 @@ public class LinuxInputDiscoveryService extends AbstractDiscoveryService {
private @NonNullByDefault({}) Future<?> discoveryJob;
public LinuxInputDiscoveryService() {
super(Collections.singleton(THING_TYPE_DEVICE), (int) TIMEOUT.getSeconds(), true);
super(Set.of(THING_TYPE_DEVICE), (int) TIMEOUT.getSeconds(), true);
}
@Override

View File

@@ -166,7 +166,7 @@ public final class LinuxInputHandler extends DeviceReadingHandler {
if (selector.selectedKeys().remove(evdevReady)) {
while (true) {
Optional<EvdevDevice.InputEvent> ev = currentDevice.nextEvent();
if (!ev.isPresent()) {
if (ev.isEmpty()) {
break;
}
handleEvent(ev.get());

View File

@@ -14,7 +14,6 @@ package org.openhab.binding.linuxinput.internal;
import static org.openhab.binding.linuxinput.internal.LinuxInputBindingConstants.THING_TYPE_DEVICE;
import java.util.Collections;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -34,7 +33,7 @@ import org.osgi.service.component.annotations.Component;
@NonNullByDefault
@Component(configurationPid = "binding.linuxinput", service = ThingHandlerFactory.class)
public class LinuxInputHandlerFactory extends BaseThingHandlerFactory {
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_DEVICE);
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_DEVICE);
@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {