Java 17 features (N-S) (#15565)
- 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 Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
@@ -20,5 +20,5 @@ package org.openhab.binding.qolsysiq.internal.client.dto.action;
|
||||
public enum ArmingActionType {
|
||||
ARM_AWAY,
|
||||
ARM_STAY,
|
||||
DISARM;
|
||||
DISARM
|
||||
}
|
||||
|
||||
@@ -22,5 +22,5 @@ public enum EventType {
|
||||
ARMING,
|
||||
ERROR,
|
||||
INFO,
|
||||
ZONE_EVENT;
|
||||
ZONE_EVENT
|
||||
}
|
||||
|
||||
@@ -19,5 +19,5 @@ package org.openhab.binding.qolsysiq.internal.client.dto.event;
|
||||
*/
|
||||
public enum InfoEventType {
|
||||
SUMMARY,
|
||||
SECURE_ARM;
|
||||
SECURE_ARM
|
||||
}
|
||||
|
||||
@@ -20,5 +20,5 @@ package org.openhab.binding.qolsysiq.internal.client.dto.event;
|
||||
public enum ZoneEventType {
|
||||
ZONE_ACTIVE,
|
||||
ZONE_ADD,
|
||||
ZONE_UPDATE;
|
||||
ZONE_UPDATE
|
||||
}
|
||||
|
||||
@@ -25,5 +25,5 @@ public enum AlarmType {
|
||||
POLICE,
|
||||
@SerializedName("")
|
||||
ZONEOPEN,
|
||||
NONE;
|
||||
NONE
|
||||
}
|
||||
|
||||
@@ -23,5 +23,5 @@ public enum PartitionStatus {
|
||||
ARM_STAY,
|
||||
DISARM,
|
||||
ENTRY_DELAY,
|
||||
EXIT_DELAY;
|
||||
EXIT_DELAY
|
||||
}
|
||||
|
||||
@@ -31,5 +31,5 @@ public enum ZoneStatus {
|
||||
@SerializedName("Idle")
|
||||
IDlE,
|
||||
@SerializedName("Tamper")
|
||||
TAMPER;
|
||||
TAMPER
|
||||
}
|
||||
|
||||
@@ -115,5 +115,5 @@ public enum ZoneType {
|
||||
@SerializedName("120")
|
||||
ZWAVE_SIREN,
|
||||
@SerializedName("121")
|
||||
COUNT;
|
||||
COUNT
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ public class QolsysIQChildDiscoveryService extends AbstractDiscoveryService
|
||||
|
||||
@Override
|
||||
public void setThingHandler(ThingHandler handler) {
|
||||
if (handler instanceof QolsysIQChildDiscoveryHandler) {
|
||||
((QolsysIQChildDiscoveryHandler) handler).setDiscoveryService(this);
|
||||
if (handler instanceof QolsysIQChildDiscoveryHandler childDiscoveryHandler) {
|
||||
childDiscoveryHandler.setDiscoveryService(this);
|
||||
this.thingHandler = handler;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -100,7 +101,7 @@ public class QolsysIQPanelHandler extends BaseBridgeHandler
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(QolsysIQChildDiscoveryService.class);
|
||||
return Set.of(QolsysIQChildDiscoveryService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -316,9 +317,9 @@ public class QolsysIQPanelHandler extends BaseBridgeHandler
|
||||
private @Nullable QolsysIQPartitionHandler partitionHandler(int partitionId) {
|
||||
for (Thing thing : getThing().getThings()) {
|
||||
ThingHandler handler = thing.getHandler();
|
||||
if (handler instanceof QolsysIQPartitionHandler) {
|
||||
if (((QolsysIQPartitionHandler) handler).getPartitionId() == partitionId) {
|
||||
return (QolsysIQPartitionHandler) handler;
|
||||
if (handler instanceof QolsysIQPartitionHandler partitionHandler) {
|
||||
if (partitionHandler.getPartitionId() == partitionId) {
|
||||
return partitionHandler;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -156,7 +157,7 @@ public class QolsysIQPartitionHandler extends BaseBridgeHandler implements Qolsy
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(QolsysIQChildDiscoveryService.class);
|
||||
return Set.of(QolsysIQChildDiscoveryService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -347,9 +348,9 @@ public class QolsysIQPartitionHandler extends BaseBridgeHandler implements Qolsy
|
||||
private @Nullable QolsysIQZoneHandler zoneHandler(int zoneId) {
|
||||
for (Thing thing : getThing().getThings()) {
|
||||
ThingHandler handler = thing.getHandler();
|
||||
if (handler instanceof QolsysIQZoneHandler) {
|
||||
if (((QolsysIQZoneHandler) handler).getZoneId() == zoneId) {
|
||||
return (QolsysIQZoneHandler) handler;
|
||||
if (handler instanceof QolsysIQZoneHandler zoneHandler) {
|
||||
if (zoneHandler.getZoneId() == zoneId) {
|
||||
return zoneHandler;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -360,8 +361,8 @@ public class QolsysIQPartitionHandler extends BaseBridgeHandler implements Qolsy
|
||||
Bridge bridge = getBridge();
|
||||
if (bridge != null) {
|
||||
BridgeHandler handler = bridge.getHandler();
|
||||
if (handler instanceof QolsysIQPanelHandler) {
|
||||
return (QolsysIQPanelHandler) handler;
|
||||
if (handler instanceof QolsysIQPanelHandler panelHandler) {
|
||||
return panelHandler;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -105,12 +105,12 @@ public class QolsysIQZoneHandler extends BaseThingHandler {
|
||||
private void initializeZone() {
|
||||
Bridge bridge = getBridge();
|
||||
BridgeHandler handler = bridge == null ? null : bridge.getHandler();
|
||||
if (bridge != null && handler instanceof QolsysIQPartitionHandler) {
|
||||
if (bridge != null && handler instanceof QolsysIQPartitionHandler partitionHandler) {
|
||||
if (handler.getThing().getStatus() != ThingStatus.ONLINE) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
|
||||
return;
|
||||
}
|
||||
Zone z = ((QolsysIQPartitionHandler) handler).getZone(getZoneId());
|
||||
Zone z = partitionHandler.getZone(getZoneId());
|
||||
if (z == null) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Zone not found in partition");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user