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:
@@ -187,8 +187,8 @@ public class BigAssFanHandler extends BaseThingHandler {
|
||||
logger.debug("Handling fan speed command for {}: {}", thing.getUID(), command);
|
||||
|
||||
// <mac;FAN;SPD;SET;0..7>
|
||||
if (command instanceof PercentType) {
|
||||
sendCommand(macAddress, ";FAN;SPD;SET;".concat(BigAssFanConverter.percentToSpeed((PercentType) command)));
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
sendCommand(macAddress, ";FAN;SPD;SET;".concat(BigAssFanConverter.percentToSpeed(percentCommand)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,52 +238,48 @@ public class BigAssFanHandler extends BaseThingHandler {
|
||||
private void handleFanLearnSpeedMin(Command command) {
|
||||
logger.debug("Handling fan learn speed minimum command {}", command);
|
||||
// <mac;FAN;SPD;SET;MIN;0..7>
|
||||
if (command instanceof PercentType) {
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
// Send min speed set command
|
||||
sendCommand(macAddress,
|
||||
";LEARN;MINSPEED;SET;".concat(BigAssFanConverter.percentToSpeed((PercentType) command)));
|
||||
fanStateMap.put(CHANNEL_FAN_LEARN_MINSPEED, (PercentType) command);
|
||||
sendCommand(macAddress, ";LEARN;MINSPEED;SET;".concat(BigAssFanConverter.percentToSpeed(percentCommand)));
|
||||
fanStateMap.put(CHANNEL_FAN_LEARN_MINSPEED, percentCommand);
|
||||
// Don't let max be less than min
|
||||
adjustMaxSpeed((PercentType) command, CHANNEL_FAN_LEARN_MAXSPEED, ";LEARN;MAXSPEED;");
|
||||
adjustMaxSpeed(percentCommand, CHANNEL_FAN_LEARN_MAXSPEED, ";LEARN;MAXSPEED;");
|
||||
}
|
||||
}
|
||||
|
||||
private void handleFanLearnSpeedMax(Command command) {
|
||||
logger.debug("Handling fan learn speed maximum command {}", command);
|
||||
// <mac;FAN;SPD;SET;MAX;0..7>
|
||||
if (command instanceof PercentType) {
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
// Send max speed set command
|
||||
sendCommand(macAddress,
|
||||
";LEARN;MAXSPEED;SET;;".concat(BigAssFanConverter.percentToSpeed((PercentType) command)));
|
||||
fanStateMap.put(CHANNEL_FAN_LEARN_MAXSPEED, (PercentType) command);
|
||||
sendCommand(macAddress, ";LEARN;MAXSPEED;SET;;".concat(BigAssFanConverter.percentToSpeed(percentCommand)));
|
||||
fanStateMap.put(CHANNEL_FAN_LEARN_MAXSPEED, percentCommand);
|
||||
// Don't let min be greater than max
|
||||
adjustMinSpeed((PercentType) command, CHANNEL_FAN_LEARN_MINSPEED, ";LEARN;MINSPEED;");
|
||||
adjustMinSpeed(percentCommand, CHANNEL_FAN_LEARN_MINSPEED, ";LEARN;MINSPEED;");
|
||||
}
|
||||
}
|
||||
|
||||
private void handleFanSpeedMin(Command command) {
|
||||
logger.debug("Handling fan speed minimum command {}", command);
|
||||
// <mac;FAN;SPD;SET;MIN;0..7>
|
||||
if (command instanceof PercentType) {
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
// Send min speed set command
|
||||
sendCommand(macAddress,
|
||||
";FAN;SPD;SET;MIN;".concat(BigAssFanConverter.percentToSpeed((PercentType) command)));
|
||||
fanStateMap.put(CHANNEL_FAN_SPEED_MIN, (PercentType) command);
|
||||
sendCommand(macAddress, ";FAN;SPD;SET;MIN;".concat(BigAssFanConverter.percentToSpeed(percentCommand)));
|
||||
fanStateMap.put(CHANNEL_FAN_SPEED_MIN, percentCommand);
|
||||
// Don't let max be less than min
|
||||
adjustMaxSpeed((PercentType) command, CHANNEL_FAN_SPEED_MAX, ";FAN;SPD;SET;MAX;");
|
||||
adjustMaxSpeed(percentCommand, CHANNEL_FAN_SPEED_MAX, ";FAN;SPD;SET;MAX;");
|
||||
}
|
||||
}
|
||||
|
||||
private void handleFanSpeedMax(Command command) {
|
||||
logger.debug("Handling fan speed maximum command {}", command);
|
||||
// <mac;FAN;SPD;SET;MAX;0..7>
|
||||
if (command instanceof PercentType) {
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
// Send max speed set command
|
||||
sendCommand(macAddress,
|
||||
";FAN;SPD;SET;MAX;".concat(BigAssFanConverter.percentToSpeed((PercentType) command)));
|
||||
fanStateMap.put(CHANNEL_FAN_SPEED_MAX, (PercentType) command);
|
||||
sendCommand(macAddress, ";FAN;SPD;SET;MAX;".concat(BigAssFanConverter.percentToSpeed(percentCommand)));
|
||||
fanStateMap.put(CHANNEL_FAN_SPEED_MAX, percentCommand);
|
||||
// Don't let min be greater than max
|
||||
adjustMinSpeed((PercentType) command, CHANNEL_FAN_SPEED_MIN, ";FAN;SPD;SET;MIN;");
|
||||
adjustMinSpeed(percentCommand, CHANNEL_FAN_SPEED_MIN, ";FAN;SPD;SET;MIN;");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,9 +360,8 @@ public class BigAssFanHandler extends BaseThingHandler {
|
||||
|
||||
logger.debug("Handling light level command {}", command);
|
||||
// <mac;LIGHT;LEVEL;SET;0..16>
|
||||
if (command instanceof PercentType) {
|
||||
sendCommand(macAddress,
|
||||
";LIGHT;LEVEL;SET;".concat(BigAssFanConverter.percentToLevel((PercentType) command)));
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
sendCommand(macAddress, ";LIGHT;LEVEL;SET;".concat(BigAssFanConverter.percentToLevel(percentCommand)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,9 +373,9 @@ public class BigAssFanHandler extends BaseThingHandler {
|
||||
|
||||
logger.debug("Handling light hue command {}", command);
|
||||
// <mac;LIGHT;COLOR;TEMP;SET;2200..5000>
|
||||
if (command instanceof PercentType) {
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
sendCommand(macAddress,
|
||||
";LIGHT;COLOR;TEMP;VALUE;SET;".concat(BigAssFanConverter.percentToHue((PercentType) command)));
|
||||
";LIGHT;COLOR;TEMP;VALUE;SET;".concat(BigAssFanConverter.percentToHue(percentCommand)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,12 +421,11 @@ public class BigAssFanHandler extends BaseThingHandler {
|
||||
|
||||
logger.debug("Handling light level minimum command {}", command);
|
||||
// <mac;LIGHT;LEVEL;MIN;0-16>
|
||||
if (command instanceof PercentType) {
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
// Send min light level set command
|
||||
sendCommand(macAddress,
|
||||
";LIGHT;LEVEL;MIN;".concat(BigAssFanConverter.percentToLevel((PercentType) command)));
|
||||
sendCommand(macAddress, ";LIGHT;LEVEL;MIN;".concat(BigAssFanConverter.percentToLevel(percentCommand)));
|
||||
// Don't let max be less than min
|
||||
adjustMaxLevel((PercentType) command);
|
||||
adjustMaxLevel(percentCommand);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,12 +437,11 @@ public class BigAssFanHandler extends BaseThingHandler {
|
||||
|
||||
logger.debug("Handling light level maximum command {}", command);
|
||||
// <mac;LIGHT;LEVEL;MAX;0-16>
|
||||
if (command instanceof PercentType) {
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
// Send max light level set command
|
||||
sendCommand(macAddress,
|
||||
";LIGHT;LEVEL;MAX;".concat(BigAssFanConverter.percentToLevel((PercentType) command)));
|
||||
sendCommand(macAddress, ";LIGHT;LEVEL;MAX;".concat(BigAssFanConverter.percentToLevel(percentCommand)));
|
||||
// Don't let min be greater than max
|
||||
adjustMinLevel((PercentType) command);
|
||||
adjustMinLevel(percentCommand);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user