Java 17 features (T-Z) (#15576)
- 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 - remove null check before instanceof Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
@@ -70,12 +70,12 @@ public class BulbDevice extends SmartHomeDevice {
|
||||
final int transitionPeriod = configuration.transitionPeriod;
|
||||
final HasErrorResponse response;
|
||||
|
||||
if (command instanceof OnOffType && CHANNELS_BULB_SWITCH.contains(channelId)) {
|
||||
response = handleOnOffType(channelId, (OnOffType) command, transitionPeriod);
|
||||
} else if (command instanceof HSBType && CHANNEL_COLOR.equals(channelId)) {
|
||||
response = handleHSBType(channelId, (HSBType) command, transitionPeriod);
|
||||
} else if (command instanceof DecimalType) {
|
||||
response = handleDecimalType(channelId, (DecimalType) command, transitionPeriod);
|
||||
if (command instanceof OnOffType onOffCommand && CHANNELS_BULB_SWITCH.contains(channelId)) {
|
||||
response = handleOnOffType(channelId, onOffCommand, transitionPeriod);
|
||||
} else if (command instanceof HSBType hsbCommand && CHANNEL_COLOR.equals(channelId)) {
|
||||
response = handleHSBType(channelId, hsbCommand, transitionPeriod);
|
||||
} else if (command instanceof DecimalType decimalCommand) {
|
||||
response = handleDecimalType(channelId, decimalCommand, transitionPeriod);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -56,11 +56,9 @@ public class DimmerDevice extends SwitchDevice {
|
||||
private boolean handleBrightnessChannel(ChannelUID channelUid, Command command) throws IOException {
|
||||
HasErrorResponse response = null;
|
||||
|
||||
if (command instanceof OnOffType) {
|
||||
response = setOnOffState(channelUid, (OnOffType) command);
|
||||
} else if (command instanceof PercentType) {
|
||||
PercentType percentCommand = (PercentType) command;
|
||||
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
response = setOnOffState(channelUid, onOffCommand);
|
||||
} else if (command instanceof PercentType percentCommand) {
|
||||
// Don't send value 0 as brightness value as it will give an error from the device.
|
||||
if (percentCommand.intValue() > 0) {
|
||||
response = commands.setDimmerBrightnessResponse(
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SwitchDevice extends SmartHomeDevice {
|
||||
|
||||
@Override
|
||||
public boolean handleCommand(ChannelUID channelUid, Command command) throws IOException {
|
||||
return command instanceof OnOffType && handleOnOffType(channelUid, (OnOffType) command);
|
||||
return command instanceof OnOffType onOffCommand && handleOnOffType(channelUid, onOffCommand);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,8 +58,8 @@ public class TPLinkSmartHomeActions implements ThingActions, ThingHandlerService
|
||||
|
||||
@Override
|
||||
public void setThingHandler(final ThingHandler handler) {
|
||||
if (handler instanceof SmartHomeHandler) {
|
||||
this.handler = (SmartHomeHandler) handler;
|
||||
if (handler instanceof SmartHomeHandler smartHomeHandler) {
|
||||
this.handler = smartHomeHandler;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user