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:
@@ -99,11 +99,10 @@ public class NoboHubBridgeHandler extends BaseBridgeHandler {
|
||||
|
||||
if (CHANNEL_HUB_ACTIVE_OVERRIDE_NAME.equals(channelUID.getId())) {
|
||||
if (ht != null && h != null) {
|
||||
if (command instanceof StringType) {
|
||||
StringType strCommand = (StringType) command;
|
||||
logger.debug("Changing override for hub {} to {}", channelUID, strCommand);
|
||||
if (command instanceof StringType stringCommand) {
|
||||
logger.debug("Changing override for hub {} to {}", channelUID, stringCommand);
|
||||
try {
|
||||
OverrideMode mode = OverrideMode.getByName(strCommand.toFullString());
|
||||
OverrideMode mode = OverrideMode.getByName(stringCommand.toFullString());
|
||||
ht.getConnection().setOverride(h, mode);
|
||||
} catch (NoboCommunicationException nce) {
|
||||
logger.debug("Failed setting override mode", nce);
|
||||
|
||||
@@ -92,8 +92,8 @@ public class NoboHubHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
@Override
|
||||
protected void removeHandler(ThingHandler thingHandler) {
|
||||
if (thingHandler instanceof NoboHubBridgeHandler) {
|
||||
unregisterDiscoveryService((NoboHubBridgeHandler) thingHandler);
|
||||
if (thingHandler instanceof NoboHubBridgeHandler bridgeHandler) {
|
||||
unregisterDiscoveryService(bridgeHandler);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -166,8 +166,7 @@ public class ZoneHandler extends BaseThingHandler {
|
||||
if (CHANNEL_ZONE_COMFORT_TEMPERATURE.equals(channelUID.getId())) {
|
||||
Zone zone = getZone();
|
||||
if (zone != null) {
|
||||
if (command instanceof DecimalType) {
|
||||
DecimalType comfortTemp = (DecimalType) command;
|
||||
if (command instanceof DecimalType comfortTemp) {
|
||||
logger.debug("Set comfort temp for zone {} to {}", zone.getName(), comfortTemp.doubleValue());
|
||||
zone.setComfortTemperature(comfortTemp.intValue());
|
||||
sendCommand(zone.generateCommandString("U00"));
|
||||
@@ -180,8 +179,7 @@ public class ZoneHandler extends BaseThingHandler {
|
||||
if (CHANNEL_ZONE_ECO_TEMPERATURE.equals(channelUID.getId())) {
|
||||
Zone zone = getZone();
|
||||
if (zone != null) {
|
||||
if (command instanceof DecimalType) {
|
||||
DecimalType ecoTemp = (DecimalType) command;
|
||||
if (command instanceof DecimalType ecoTemp) {
|
||||
logger.debug("Set eco temp for zone {} to {}", zone.getName(), ecoTemp.doubleValue());
|
||||
zone.setEcoTemperature(ecoTemp.intValue());
|
||||
sendCommand(zone.generateCommandString("U00"));
|
||||
@@ -193,8 +191,7 @@ public class ZoneHandler extends BaseThingHandler {
|
||||
if (CHANNEL_ZONE_ACTIVE_WEEK_PROFILE.equals(channelUID.getId())) {
|
||||
Zone zone = getZone();
|
||||
if (zone != null) {
|
||||
if (command instanceof DecimalType) {
|
||||
DecimalType weekProfileId = (DecimalType) command;
|
||||
if (command instanceof DecimalType weekProfileId) {
|
||||
logger.debug("Set week profile for zone {} to {}", zone.getName(), weekProfileId);
|
||||
zone.setWeekProfile(weekProfileId.intValue());
|
||||
sendCommand(zone.generateCommandString("U00"));
|
||||
|
||||
@@ -82,8 +82,8 @@ public class NoboHubDiscoveryService extends AbstractDiscoveryService implements
|
||||
|
||||
@Override
|
||||
public void setThingHandler(ThingHandler thingHandler) {
|
||||
if (thingHandler instanceof NoboHubBridgeHandler) {
|
||||
this.hubBridgeHandler = (NoboHubBridgeHandler) thingHandler;
|
||||
if (thingHandler instanceof NoboHubBridgeHandler bridgeHandler) {
|
||||
this.hubBridgeHandler = bridgeHandler;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Hub {
|
||||
}
|
||||
|
||||
public static Hub fromH05(String h05) throws NoboDataException {
|
||||
String parts[] = h05.split(" ", 8);
|
||||
String[] parts = h05.split(" ", 8);
|
||||
|
||||
if (parts.length != 8) {
|
||||
throw new NoboDataException(
|
||||
|
||||
@@ -31,7 +31,7 @@ public final class Temperature {
|
||||
}
|
||||
|
||||
public static Temperature fromY02(String y02) throws NoboDataException {
|
||||
String parts[] = y02.split(" ", 3);
|
||||
String[] parts = y02.split(" ", 3);
|
||||
if (parts.length != 3) {
|
||||
throw new NoboDataException(
|
||||
String.format("Unexpected number of parts from hub on Y02 call: %d", parts.length));
|
||||
|
||||
@@ -43,7 +43,7 @@ public final class Zone {
|
||||
}
|
||||
|
||||
public static Zone fromH01(String h01) throws NoboDataException {
|
||||
String parts[] = h01.split(" ", 8);
|
||||
String[] parts = h01.split(" ", 8);
|
||||
|
||||
if (parts.length != 8) {
|
||||
throw new NoboDataException(
|
||||
|
||||
Reference in New Issue
Block a user