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

@@ -12,9 +12,6 @@
*/
package org.openhab.binding.draytonwiser.internal;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -109,9 +106,8 @@ public class DraytonWiserBindingConstants {
public static final String CHANNEL_SMARTPLUG_INSTANTANEOUS_POWER = "plugInstantaneousPower";
public static final String CHANNEL_SMARTPLUG_ENERGY_DELIVERED = "plugEnergyDelivered";
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
.unmodifiableSet(new HashSet<>(Arrays.asList(THING_TYPE_CONTROLLER, THING_TYPE_ROOM, THING_TYPE_ROOMSTAT,
THING_TYPE_BRIDGE, THING_TYPE_ITRV, THING_TYPE_HOTWATER, THING_TYPE_SMARTPLUG)));
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_CONTROLLER, THING_TYPE_ROOM,
THING_TYPE_ROOMSTAT, THING_TYPE_BRIDGE, THING_TYPE_ITRV, THING_TYPE_HOTWATER, THING_TYPE_SMARTPLUG);
// Lookups from text representations to useful values

View File

@@ -202,8 +202,8 @@ public class DraytonWiserDiscoveryService extends AbstractDiscoveryService
@Override
public void setThingHandler(@Nullable final ThingHandler handler) {
if (handler instanceof HeatHubHandler) {
bridgeHandler = (HeatHubHandler) handler;
if (handler instanceof HeatHubHandler hubHandler) {
bridgeHandler = hubHandler;
bridgeUID = handler.getThing().getUID();
} else {
bridgeHandler = null;

View File

@@ -15,7 +15,6 @@ package org.openhab.binding.draytonwiser.internal.discovery;
import static org.openhab.binding.draytonwiser.internal.DraytonWiserBindingConstants.*;
import java.net.InetAddress;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -50,7 +49,7 @@ public class DraytonWiserMDNSDiscoveryParticipant implements MDNSDiscoveryPartic
@Override
public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
return Collections.singleton(THING_TYPE_BRIDGE);
return Set.of(THING_TYPE_BRIDGE);
}
@Override

View File

@@ -13,8 +13,8 @@
package org.openhab.binding.draytonwiser.internal.handler;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
@@ -71,7 +71,7 @@ public class HeatHubHandler extends BaseBridgeHandler {
@Override
public Collection<Class<? extends ThingHandlerService>> getServices() {
return Collections.singleton(DraytonWiserDiscoveryService.class);
return Set.of(DraytonWiserDiscoveryService.class);
}
public void setDiscoveryService(final DraytonWiserRefreshListener discoveryService) {

View File

@@ -59,8 +59,8 @@ public class RoomHandler extends DraytonWiserThingHandler<RoomDTO> {
protected void handleCommand(final String channelId, final Command command) throws DraytonWiserApiException {
switch (channelId) {
case CHANNEL_CURRENT_SETPOINT:
if (command instanceof QuantityType) {
setSetPoint((QuantityType<?>) command);
if (command instanceof QuantityType quantityCommand) {
setSetPoint(quantityCommand);
}
break;
case CHANNEL_MANUAL_MODE_STATE:
@@ -69,8 +69,8 @@ public class RoomHandler extends DraytonWiserThingHandler<RoomDTO> {
}
break;
case CHANNEL_ROOM_BOOST_DURATION:
if (command instanceof DecimalType) {
setBoostDuration(Math.round((((DecimalType) command).floatValue() * 60)));
if (command instanceof DecimalType decimalCommand) {
setBoostDuration(Math.round((decimalCommand.floatValue() * 60)));
}
break;
case CHANNEL_ROOM_WINDOW_STATE_DETECTION: