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:
Holger Friedrich
2023-09-05 22:30:16 +02:00
committed by GitHub
parent a0dc5c05f2
commit cf10b3e9c7
486 changed files with 2053 additions and 1955 deletions

View File

@@ -236,16 +236,16 @@ public class DanfossAirUnit {
}
private DecimalType setNumberTypeRegister(Command cmd, byte[] register) throws IOException {
if (cmd instanceof DecimalType) {
byte value = (byte) ((DecimalType) cmd).intValue();
if (cmd instanceof DecimalType decimalCommand) {
byte value = (byte) decimalCommand.intValue();
set(REGISTER_1_WRITE, register, value);
}
return new DecimalType(BigDecimal.valueOf(getByte(REGISTER_1_READ, register)));
}
private PercentType setPercentTypeRegister(Command cmd, byte[] register) throws IOException {
if (cmd instanceof PercentType) {
byte value = (byte) ((((PercentType) cmd).intValue() + 5) / 10);
if (cmd instanceof PercentType percentCommand) {
byte value = (byte) ((percentCommand.intValue() + 5) / 10);
set(REGISTER_1_WRITE, register, value);
}
return new PercentType(BigDecimal.valueOf(getByte(REGISTER_1_READ, register) * 10));

View File

@@ -52,6 +52,7 @@ public class DanfossAirUnitCommunicationController implements CommunicationContr
this.port = port;
}
@Override
public synchronized void connect() throws IOException {
if (connected) {
return;
@@ -64,6 +65,7 @@ public class DanfossAirUnitCommunicationController implements CommunicationContr
connected = true;
}
@Override
public synchronized void disconnect() {
if (!connected) {
return;
@@ -83,10 +85,12 @@ public class DanfossAirUnitCommunicationController implements CommunicationContr
connected = false;
}
@Override
public byte[] sendRobustRequest(byte[] operation, byte[] register) throws IOException {
return sendRobustRequest(operation, register, EMPTY);
}
@Override
public synchronized byte[] sendRobustRequest(byte[] operation, byte[] register, byte[] value) throws IOException {
connect();
byte[] request = new byte[4 + value.length];

View File

@@ -14,7 +14,6 @@ package org.openhab.binding.danfossairunit.internal;
import static org.openhab.binding.danfossairunit.internal.DanfossAirUnitBindingConstants.THING_TYPE_AIRUNIT;
import java.util.Collections;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -38,7 +37,7 @@ import org.osgi.service.component.annotations.Component;
@Component(configurationPid = "binding.danfossairunit", service = ThingHandlerFactory.class)
public class DanfossAirUnitHandlerFactory extends BaseThingHandlerFactory {
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_AIRUNIT);
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_AIRUNIT);
@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {