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:
@@ -12,7 +12,6 @@
|
||||
*/
|
||||
package org.openhab.binding.luxtronikheatpump.internal;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
@@ -31,5 +30,5 @@ public class LuxtronikHeatpumpBindingConstants {
|
||||
|
||||
public static final ThingTypeUID THING_TYPE_HEATPUMP = new ThingTypeUID(BINDING_ID, "heatpump");
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_HEATPUMP);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_HEATPUMP);
|
||||
}
|
||||
|
||||
@@ -112,9 +112,7 @@ public class LuxtronikHeatpumpHandler extends BaseThingHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (command instanceof QuantityType) {
|
||||
QuantityType<?> value = (QuantityType<?>) command;
|
||||
|
||||
if (command instanceof QuantityType value) {
|
||||
Unit<?> unit = channel.getUnit();
|
||||
if (unit != null) {
|
||||
value = value.toUnit(unit);
|
||||
@@ -123,8 +121,8 @@ public class LuxtronikHeatpumpHandler extends BaseThingHandler {
|
||||
command = new DecimalType(value.floatValue());
|
||||
}
|
||||
|
||||
if (command instanceof OnOffType) {
|
||||
command = ((OnOffType) command) == OnOffType.ON ? new DecimalType(1) : DecimalType.ZERO;
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
command = onOffCommand == OnOffType.ON ? new DecimalType(1) : DecimalType.ZERO;
|
||||
}
|
||||
|
||||
if (!(command instanceof DecimalType)) {
|
||||
|
||||
@@ -109,7 +109,7 @@ public enum HeatpumpType {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static final HeatpumpType fromCode(Integer code) {
|
||||
public static HeatpumpType fromCode(Integer code) {
|
||||
for (HeatpumpType error : HeatpumpType.values()) {
|
||||
if (error.code.equals(code)) {
|
||||
return error;
|
||||
|
||||
Reference in New Issue
Block a user