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:
Holger Friedrich
2023-09-13 08:03:31 +02:00
committed by GitHub
parent 641b482551
commit ab58f4ffb4
471 changed files with 1624 additions and 1868 deletions

View File

@@ -38,9 +38,7 @@ public class PHCHelper {
String thingID = StringUtils.padLeft(Integer.toBinaryString(moduleAddr & 0xFF).trim(), 5, "0");
thingID = new StringBuilder(thingID).reverse().toString();
ThingUID thingUID = new ThingUID(thingTypeUID, thingID);
return thingUID;
return new ThingUID(thingTypeUID, thingID);
}
/**

View File

@@ -77,9 +77,9 @@ public class PHCBridgeHandler extends BaseBridgeHandler implements SerialPortEve
private final BlockingQueue<QueueObject> sendQueue = new LinkedBlockingQueue<>();
private final ScheduledThreadPoolExecutor threadPoolExecutor = new ScheduledThreadPoolExecutor(3);
private final byte emLedOutputState[] = new byte[32];
private final byte amOutputState[] = new byte[32];
private final byte dmOutputState[] = new byte[32];
private final byte[] emLedOutputState = new byte[32];
private final byte[] amOutputState = new byte[32];
private final byte[] dmOutputState = new byte[32];
private final List<Byte> modules = new ArrayList<>();
@@ -570,7 +570,8 @@ public class PHCBridgeHandler extends BaseBridgeHandler implements SerialPortEve
private void sendDim(byte moduleAddress, byte channel, Command command, short dimTime) {
byte module = (byte) (moduleAddress | 0xA0);
byte[] cmd = new byte[(command instanceof PercentType && !(((PercentType) command).byteValue() == 0)) ? 3 : 1];
byte[] cmd = new byte[(command instanceof PercentType percentCommand && percentCommand.byteValue() != 0) ? 3
: 1];
cmd[0] = (byte) (channel << 5);

View File

@@ -157,8 +157,8 @@ public class PHCHandler extends BaseThingHandler {
}
ThingHandler handler = bridge.getHandler();
if (handler instanceof PHCBridgeHandler) {
bridgeHandler = (PHCBridgeHandler) handler;
if (handler instanceof PHCBridgeHandler phcBridgeHandler) {
bridgeHandler = phcBridgeHandler;
} else {
logger.debug("No available bridge handler for {}.", bridge.getUID());