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:
@@ -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(".", "-");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()))
|
||||
|
||||
Reference in New Issue
Block a user