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:
Holger Friedrich
2023-09-05 22:30:16 +02:00
committed by GitHub
parent a0dc5c05f2
commit cf10b3e9c7
486 changed files with 2053 additions and 1955 deletions

View File

@@ -90,7 +90,7 @@ public class BroadlinkDiscoveryService extends AbstractDiscoveryService {
Integer.toHexString(dev.getDeviceType()), dev.getHost(), dev.getMac());
ThingUID thingUID;
String id = dev.getHost().replaceAll("\\.", "-");
String id = dev.getHost().replace(".", "-");
logger.debug("Device ID with IP address replacement: {}", id);
try {
id = getHostnameWithoutDomain(InetAddress.getByName(dev.getHost()).getHostName());
@@ -187,11 +187,11 @@ public class BroadlinkDiscoveryService extends AbstractDiscoveryService {
if (hostname.matches(broadlinkRegex)) {
String[] dotSeparatedString = hostname.split("\\.");
logger.debug("Found original broadlink DNS name {}, removing domain", hostname);
return dotSeparatedString[0].replaceAll("\\.", "-");
return dotSeparatedString[0].replace(".", "-");
} else {
logger.debug("DNS name does not match original broadlink name: {}, using it without modification. ",
hostname);
return hostname.replaceAll("\\.", "-");
return hostname.replace(".", "-");
}
}
}

View File

@@ -159,9 +159,9 @@ public class FloureonThermostatHandler extends BroadlinkBaseHandler {
private void handleSetpointCommand(ChannelUID channelUID, Command command) {
FloureonDevice floureonDevice = this.floureonDevice;
if (command instanceof QuantityType && floureonDevice != null) {
if (command instanceof QuantityType quantityCommand && floureonDevice != null) {
try {
QuantityType<?> temperatureQuantityType = ((QuantityType<?>) command).toUnit(SIUnits.CELSIUS);
QuantityType<?> temperatureQuantityType = quantityCommand.toUnit(SIUnits.CELSIUS);
if (temperatureQuantityType != null) {
floureonDevice.setThermostatTemp(temperatureQuantityType.doubleValue());
} else {
@@ -211,8 +211,8 @@ public class FloureonThermostatHandler extends BroadlinkBaseHandler {
}
private void handleSetTimeCommand(ChannelUID channelUID, Command command) {
if (command instanceof DateTimeType) {
ZonedDateTime zonedDateTime = ((DateTimeType) command).getZonedDateTime();
if (command instanceof DateTimeType dateTimeCommand) {
ZonedDateTime zonedDateTime = dateTimeCommand.getZonedDateTime();
try {
new SetTimeCommand(tob(zonedDateTime.getHour()), tob(zonedDateTime.getMinute()),
tob(zonedDateTime.getSecond()), tob(zonedDateTime.getDayOfWeek().getValue()))