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:
@@ -42,8 +42,8 @@ public class ZmActions implements ThingActions {
|
||||
|
||||
@Override
|
||||
public void setThingHandler(@Nullable ThingHandler handler) {
|
||||
if (handler instanceof ZmMonitorHandler) {
|
||||
this.handler = (ZmMonitorHandler) handler;
|
||||
if (handler instanceof ZmMonitorHandler zmMonitorHandler) {
|
||||
this.handler = zmMonitorHandler;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,8 +70,8 @@ public class MonitorDiscoveryService extends AbstractDiscoveryService implements
|
||||
|
||||
@Override
|
||||
public void setThingHandler(@Nullable ThingHandler handler) {
|
||||
if (handler instanceof ZmBridgeHandler) {
|
||||
bridgeHandler = (ZmBridgeHandler) handler;
|
||||
if (handler instanceof ZmBridgeHandler zmBridgeHandler) {
|
||||
bridgeHandler = zmBridgeHandler;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@ public class ZmBridgeHandler extends BaseBridgeHandler {
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(MonitorDiscoveryService.class);
|
||||
return Set.of(MonitorDiscoveryService.class);
|
||||
}
|
||||
|
||||
public boolean isBackgroundDiscoveryEnabled() {
|
||||
@@ -294,8 +294,7 @@ public class ZmBridgeHandler extends BaseBridgeHandler {
|
||||
try {
|
||||
ContentResponse response = request.send();
|
||||
if (response.getStatus() == HttpStatus.OK_200) {
|
||||
RawType image = new RawType(response.getContent(), response.getHeaders().get(HttpHeader.CONTENT_TYPE));
|
||||
return image;
|
||||
return new RawType(response.getContent(), response.getHeaders().get(HttpHeader.CONTENT_TYPE));
|
||||
} else {
|
||||
errorMsg = String.format("HTTP GET failed: %d, %s", response.getStatus(), response.getReason());
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ import static org.openhab.binding.zoneminder.internal.ZmBindingConstants.*;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -125,8 +125,8 @@ public class ZmMonitorHandler extends BaseThingHandler {
|
||||
}
|
||||
break;
|
||||
case CHANNEL_ENABLE:
|
||||
if (command instanceof OnOffType) {
|
||||
localHandler.setEnabled(monitorId, (OnOffType) command);
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
localHandler.setEnabled(monitorId, onOffCommand);
|
||||
logger.debug("Monitor {}: Set monitor enable to {}", monitorId, command);
|
||||
}
|
||||
break;
|
||||
@@ -147,7 +147,7 @@ public class ZmMonitorHandler extends BaseThingHandler {
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(ZmActions.class);
|
||||
return Set.of(ZmActions.class);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
||||
Reference in New Issue
Block a user