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

@@ -173,9 +173,7 @@ public class SinopeGatewayHandler extends ConfigStatusBridgeHandler {
InputStream inputStream = clientSocket.getInputStream();
outToServer.write(command.getPayload());
outToServer.flush();
SinopeAnswer answ = command.getReplyAnswer(inputStream);
return answ;
return command.getReplyAnswer(inputStream);
}
synchronized SinopeAnswer execute(SinopeDataRequest command) throws UnknownHostException, IOException {

View File

@@ -67,12 +67,12 @@ public class SinopeThermostatHandler extends BaseThingHandler {
if (getSinopeGatewayHandler() != null) {
try {
if (SinopeBindingConstants.CHANNEL_SETTEMP.equals(channelUID.getId())
&& command instanceof QuantityType) {
setSetpointTemp(((QuantityType<?>) command).floatValue());
&& command instanceof QuantityType quantityCommand) {
setSetpointTemp(quantityCommand.floatValue());
}
if (SinopeBindingConstants.CHANNEL_SETMODE.equals(channelUID.getId())
&& command instanceof DecimalType) {
setSetpointMode(((DecimalType) command).intValue());
&& command instanceof DecimalType decimalCommand) {
setSetpointMode(decimalCommand.intValue());
}
} catch (IOException e) {
logger.debug("Cannot handle command for channel {} because of {}", channelUID.getId(),

View File

@@ -162,7 +162,7 @@ public abstract class SinopeDataRequest extends SinopeRequest {
@Override
protected byte[] getFrameData() {
int appDataLen = getAppDataSize();
byte b[] = new byte[seq.length + 1 + 1 + 1 + res3.length + res4.length + dstDeviceId.length + 1 + appDataLen];
byte[] b = new byte[seq.length + 1 + 1 + 1 + res3.length + res4.length + dstDeviceId.length + 1 + appDataLen];
ByteBuffer bb = ByteBuffer.wrap(b);

View File

@@ -25,7 +25,7 @@ public class CRC8 implements Checksum {
private final int init;
/** The Constant crcTable. */
private static final int crcTable[] = { 0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31,
private static final int[] crcTable = { 0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31,
0x24, 0x23, 0x2a, 0x2d, 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65, 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53,
0x5a, 0x5d, 0xe0, 0xe7, 0xee, 0xe9, 0xfc, 0xfb, 0xf2, 0xf5, 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd,
0x90, 0x97, 0x9e, 0x99, 0x8c, 0x8b, 0x82, 0x85, 0xa8, 0xaf, 0xa6, 0xa1, 0xb4, 0xb3, 0xba, 0xbd, 0xc7, 0xc0,
@@ -67,6 +67,7 @@ public class CRC8 implements Checksum {
*
* @param buffer the buffer
*/
@Override
public void update(byte[] buffer) {
update(buffer, 0, buffer.length);
}