Java 17 features (A-G) (#15516)
- 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:
@@ -233,15 +233,15 @@ public class DSCAlarmMessage {
|
||||
case UserClosing: /* 700 */
|
||||
user = message.substring(4);
|
||||
name = name.concat(": " + user);
|
||||
description = codeReceived + ": Partition " + String.valueOf(partition)
|
||||
+ " has been armed by user " + user + ".";
|
||||
description = codeReceived + ": Partition " + partition + " has been armed by user " + user
|
||||
+ ".";
|
||||
messageType = DSCAlarmMessageType.PARTITION_EVENT;
|
||||
break;
|
||||
case UserOpening: /* 750 */
|
||||
user = message.substring(4);
|
||||
name = name.concat(": " + user);
|
||||
description = codeReceived + ": Partition " + String.valueOf(partition)
|
||||
+ " has been disarmed by user " + user + ".";
|
||||
description = codeReceived + ": Partition " + partition + " has been disarmed by user " + user
|
||||
+ ".";
|
||||
messageType = DSCAlarmMessageType.PARTITION_EVENT;
|
||||
break;
|
||||
|
||||
|
||||
@@ -97,8 +97,8 @@ public class DSCAlarmDiscoveryService extends AbstractDiscoveryService {
|
||||
break;
|
||||
case PARTITION:
|
||||
if (partitionNumber >= 1 && partitionNumber <= 8) {
|
||||
thingID = "partition" + String.valueOf(partitionNumber);
|
||||
thingLabel = "Partition " + String.valueOf(partitionNumber);
|
||||
thingID = "partition" + partitionNumber;
|
||||
thingLabel = "Partition " + partitionNumber;
|
||||
properties = new HashMap<>(0);
|
||||
thingUID = new ThingUID(DSCAlarmBindingConstants.PARTITION_THING_TYPE, bridge.getUID(), thingID);
|
||||
properties.put(DSCAlarmPartitionConfiguration.PARTITION_NUMBER, partitionNumber);
|
||||
@@ -107,8 +107,8 @@ public class DSCAlarmDiscoveryService extends AbstractDiscoveryService {
|
||||
break;
|
||||
case ZONE:
|
||||
if (zoneNumber >= 1 && zoneNumber <= 64) {
|
||||
thingID = "zone" + String.valueOf(zoneNumber);
|
||||
thingLabel = "Zone " + String.valueOf(zoneNumber);
|
||||
thingID = "zone" + zoneNumber;
|
||||
thingLabel = "Zone " + zoneNumber;
|
||||
properties = new HashMap<>(0);
|
||||
thingUID = new ThingUID(DSCAlarmBindingConstants.ZONE_THING_TYPE, bridge.getUID(), thingID);
|
||||
properties.put(DSCAlarmZoneConfiguration.ZONE_NUMBER, zoneNumber);
|
||||
|
||||
@@ -136,7 +136,7 @@ public class EnvisalinkBridgeDiscovery {
|
||||
* @return
|
||||
*/
|
||||
private long convertIPToNumber(String ipAddress) {
|
||||
String octets[] = ipAddress.split("\\.");
|
||||
String[] octets = ipAddress.split("\\.");
|
||||
|
||||
if (octets.length != 4) {
|
||||
throw new IllegalArgumentException("Invalid IP address: " + ipAddress);
|
||||
|
||||
@@ -202,17 +202,17 @@ public class PanelThingHandler extends DSCAlarmBaseThingHandler {
|
||||
updateState(channelUID, new StringType(String.valueOf(-1)));
|
||||
break;
|
||||
case PANEL_TIME_STAMP:
|
||||
if (command instanceof OnOffType) {
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
cmd = command == OnOffType.ON ? 1 : 0;
|
||||
dscAlarmBridgeHandler.sendCommand(DSCAlarmCode.TimeStampControl, String.valueOf(cmd));
|
||||
updateState(channelUID, (OnOffType) command);
|
||||
updateState(channelUID, onOffCommand);
|
||||
}
|
||||
break;
|
||||
case PANEL_TIME_BROADCAST:
|
||||
if (command instanceof OnOffType) {
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
cmd = command == OnOffType.ON ? 1 : 0;
|
||||
dscAlarmBridgeHandler.sendCommand(DSCAlarmCode.TimeDateBroadcastControl, String.valueOf(cmd));
|
||||
updateState(channelUID, (OnOffType) command);
|
||||
updateState(channelUID, onOffCommand);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -107,7 +107,7 @@ public class ZoneThingHandler extends DSCAlarmBaseThingHandler {
|
||||
|
||||
if (dscAlarmBridgeHandler != null && dscAlarmBridgeHandler.isConnected()
|
||||
&& channelUID.getId().equals(ZONE_BYPASS_MODE)) {
|
||||
String data = String.valueOf(getPartitionNumber()) + "*1" + String.format("%02d", getZoneNumber()) + "#";
|
||||
String data = getPartitionNumber() + "*1" + String.format("%02d", getZoneNumber()) + "#";
|
||||
|
||||
dscAlarmBridgeHandler.sendCommand(DSCAlarmCode.KeySequence, data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user