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

@@ -35,7 +35,7 @@ public class AirbaseZoneInfo {
private static final Logger LOGGER = LoggerFactory.getLogger(AirbaseZoneInfo.class);
public String zonenames = "";
public boolean zone[] = new boolean[8];
public boolean[] zone = new boolean[8];
private AirbaseZoneInfo() {
}

View File

@@ -18,10 +18,10 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
@@ -65,7 +65,7 @@ public class DaikinACUnitDiscoveryService extends AbstractDiscoveryService {
private @Nullable ScheduledFuture<?> backgroundFuture;
public DaikinACUnitDiscoveryService() {
super(Collections.singleton(DaikinBindingConstants.THING_TYPE_AC_UNIT), 600, true);
super(Set.of(DaikinBindingConstants.THING_TYPE_AC_UNIT), 600, true);
}
@Override

View File

@@ -159,20 +159,20 @@ public class DaikinAcUnitHandler extends DaikinBaseHandler {
throws DaikinCommunicationException {
switch (channelUID.getId()) {
case DaikinBindingConstants.CHANNEL_AC_FAN_DIR:
if (command instanceof StringType) {
changeFanDir(((StringType) command).toString());
if (command instanceof StringType stringCommand) {
changeFanDir(stringCommand.toString());
return true;
}
break;
case DaikinBindingConstants.CHANNEL_AC_SPECIALMODE:
if (command instanceof StringType) {
changeSpecialMode(((StringType) command).toString());
if (command instanceof StringType stringCommand) {
changeSpecialMode(stringCommand.toString());
return true;
}
break;
case DaikinBindingConstants.CHANNEL_AC_STREAMER:
if (command instanceof OnOffType) {
changeStreamer(((OnOffType) command).equals(OnOffType.ON));
if (command instanceof OnOffType onOffCommand) {
changeStreamer(onOffCommand.equals(OnOffType.ON));
return true;
}
break;

View File

@@ -102,8 +102,8 @@ public abstract class DaikinBaseHandler extends BaseThingHandler {
}
switch (channelUID.getId()) {
case DaikinBindingConstants.CHANNEL_AC_POWER:
if (command instanceof OnOffType) {
changePower(((OnOffType) command).equals(OnOffType.ON));
if (command instanceof OnOffType onOffCommand) {
changePower(onOffCommand.equals(OnOffType.ON));
return;
}
break;
@@ -114,8 +114,8 @@ public abstract class DaikinBaseHandler extends BaseThingHandler {
break;
case DaikinBindingConstants.CHANNEL_AIRBASE_AC_FAN_SPEED:
case DaikinBindingConstants.CHANNEL_AC_FAN_SPEED:
if (command instanceof StringType) {
changeFanSpeed(((StringType) command).toString());
if (command instanceof StringType stringCommand) {
changeFanSpeed(stringCommand.toString());
return;
}
break;
@@ -126,8 +126,8 @@ public abstract class DaikinBaseHandler extends BaseThingHandler {
}
break;
case DaikinBindingConstants.CHANNEL_AC_MODE:
if (command instanceof StringType) {
changeMode(((StringType) command).toString());
if (command instanceof StringType stringCommand) {
changeMode(stringCommand.toString());
return;
}
break;
@@ -214,8 +214,8 @@ public abstract class DaikinBaseHandler extends BaseThingHandler {
*/
private boolean changeSetPoint(Command command) throws DaikinCommunicationException {
double newTemperature;
if (command instanceof DecimalType) {
newTemperature = ((DecimalType) command).doubleValue();
if (command instanceof DecimalType decimalCommand) {
newTemperature = decimalCommand.doubleValue();
} else if (command instanceof QuantityType) {
newTemperature = ((QuantityType<Temperature>) command).toUnit(SIUnits.CELSIUS).doubleValue();
} else {