Java 17 features (H-M) (#15520)
- 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:
@@ -21,5 +21,5 @@ import com.google.gson.annotations.SerializedName;
|
||||
*/
|
||||
public class GetIndependentDevicesByHomeResponse extends AbstractResponse {
|
||||
@SerializedName("deviceInfo")
|
||||
public DeviceDTO devices[] = new DeviceDTO[0];
|
||||
public DeviceDTO[] devices = new DeviceDTO[0];
|
||||
}
|
||||
|
||||
@@ -372,8 +372,8 @@ public class MillheatAccountHandler extends BaseBridgeHandler {
|
||||
final Optional<Room> optionalRoom = model.findRoomById(roomId);
|
||||
if (optionalHome.isPresent() && optionalRoom.isPresent()) {
|
||||
final SetRoomTempRequest req = new SetRoomTempRequest(optionalHome.get(), optionalRoom.get());
|
||||
if (command instanceof QuantityType<?>) {
|
||||
final int newTemp = (int) ((QuantityType<?>) command).longValue();
|
||||
if (command instanceof QuantityType<?> quantityCommand) {
|
||||
final int newTemp = (int) quantityCommand.longValue();
|
||||
switch (mode) {
|
||||
case SLEEP:
|
||||
req.sleepTemp = newTemp;
|
||||
@@ -404,8 +404,8 @@ public class MillheatAccountHandler extends BaseBridgeHandler {
|
||||
@Nullable final Command fanCommand) {
|
||||
model.findHeaterByMacOrId(macAddress, heaterId).ifPresent(heater -> {
|
||||
int setTemp = heater.getTargetTemp();
|
||||
if (temperatureCommand instanceof QuantityType<?>) {
|
||||
setTemp = (int) ((QuantityType<?>) temperatureCommand).longValue();
|
||||
if (temperatureCommand instanceof QuantityType<?> temperature) {
|
||||
setTemp = (int) temperature.longValue();
|
||||
}
|
||||
boolean masterOnOff = heater.powerStatus();
|
||||
if (masterOnOffCommand != null) {
|
||||
|
||||
@@ -68,9 +68,9 @@ public class MillheatHomeHandler extends MillheatBaseThingHandler {
|
||||
updateState(channelUID, new QuantityType<>(home.getHolidayTemp(), SIUnits.CELSIUS));
|
||||
} else if (command instanceof QuantityType<?>) {
|
||||
updateVacationModeProperty(home, SetHolidayParameterRequest.PROP_TEMP, command);
|
||||
} else if (command instanceof DecimalType) {
|
||||
} else if (command instanceof DecimalType decimalCommand) {
|
||||
updateVacationModeProperty(home, SetHolidayParameterRequest.PROP_TEMP,
|
||||
new QuantityType<>((DecimalType) command, SIUnits.CELSIUS));
|
||||
new QuantityType<>(decimalCommand, SIUnits.CELSIUS));
|
||||
}
|
||||
} else if (CHANNEL_HOME_VACATION_MODE.equals(channelUID.getId())) {
|
||||
if (command instanceof RefreshType) {
|
||||
|
||||
@@ -60,7 +60,7 @@ public class MillheatModel {
|
||||
if (macAddress != null) {
|
||||
heater = findHeaterByMac(macAddress);
|
||||
}
|
||||
if (!heater.isPresent() && id != null) {
|
||||
if (heater.isEmpty() && id != null) {
|
||||
heater = findHeaterById(id);
|
||||
}
|
||||
return heater;
|
||||
|
||||
Reference in New Issue
Block a user