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:
@@ -87,16 +87,14 @@ public class UPBController {
|
||||
}
|
||||
|
||||
public void deviceAdded(final ThingHandler childHandler, final Thing childThing) {
|
||||
if (childHandler instanceof UPBThingHandler) {
|
||||
final UPBThingHandler hnd = (UPBThingHandler) childHandler;
|
||||
things.put(mkAddr(hnd.getNetworkId(), hnd.getUnitId()), hnd);
|
||||
if (childHandler instanceof UPBThingHandler upbThingHandler) {
|
||||
things.put(mkAddr(upbThingHandler.getNetworkId(), upbThingHandler.getUnitId()), upbThingHandler);
|
||||
}
|
||||
}
|
||||
|
||||
public void deviceRemoved(final ThingHandler childHandler, final Thing childThing) {
|
||||
if (childHandler instanceof UPBThingHandler) {
|
||||
final UPBThingHandler hnd = (UPBThingHandler) childHandler;
|
||||
things.remove(mkAddr(hnd.getNetworkId(), hnd.getUnitId()), hnd);
|
||||
if (childHandler instanceof UPBThingHandler upbThingHandler) {
|
||||
things.remove(mkAddr(upbThingHandler.getNetworkId(), upbThingHandler.getUnitId()), upbThingHandler);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -144,8 +144,8 @@ public class UPBThingHandler extends BaseThingHandler {
|
||||
message = MessageBuilder.forCommand(ACTIVATE);
|
||||
} else if (cmd == OnOffType.OFF) {
|
||||
message = MessageBuilder.forCommand(DEACTIVATE);
|
||||
} else if (cmd instanceof PercentType) {
|
||||
message = MessageBuilder.forCommand(GOTO).args(((PercentType) cmd).byteValue());
|
||||
} else if (cmd instanceof PercentType percentCommand) {
|
||||
message = MessageBuilder.forCommand(GOTO).args(percentCommand.byteValue());
|
||||
} else if (cmd == RefreshType.REFRESH) {
|
||||
refreshDeviceState();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user