Java 17 features (T-Z) (#15576)
- 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:
@@ -87,7 +87,7 @@ public class MyWarmupApi {
|
||||
|
||||
AuthResponseDTO ar = GSON.fromJson(response.getContentAsString(), AuthResponseDTO.class);
|
||||
|
||||
if (ar != null && ar.getStatus() != null && ar.getStatus().getResult().equals("success")) {
|
||||
if (ar != null && ar.getStatus() != null && "success".equals(ar.getStatus().getResult())) {
|
||||
authToken = ar.getResponse().getToken();
|
||||
} else {
|
||||
throw new MyWarmupApiException("Authentication Failed");
|
||||
@@ -101,9 +101,11 @@ public class MyWarmupApi {
|
||||
* @throws MyWarmupApiException API callout error
|
||||
*/
|
||||
public synchronized QueryResponseDTO getStatus() throws MyWarmupApiException {
|
||||
return callWarmupGraphQL("query QUERY { user { locations{ id name "
|
||||
+ " rooms { id roomName runMode overrideDur targetTemp currentTemp "
|
||||
+ " thermostat4ies{ deviceSN lastPoll }}}}}");
|
||||
return callWarmupGraphQL("""
|
||||
query QUERY { user { locations{ id name \
|
||||
rooms { id roomName runMode overrideDur targetTemp currentTemp \
|
||||
thermostat4ies{ deviceSN lastPoll }}}}}\
|
||||
""");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,7 +144,7 @@ public class MyWarmupApi {
|
||||
|
||||
QueryResponseDTO qr = GSON.fromJson(response.getContentAsString(), QueryResponseDTO.class);
|
||||
|
||||
if (qr != null && qr.getStatus().equals("success")) {
|
||||
if (qr != null && "success".equals(qr.getStatus())) {
|
||||
return qr;
|
||||
} else {
|
||||
throw new MyWarmupApiException("Unexpected reponse from API");
|
||||
|
||||
@@ -103,8 +103,8 @@ public class WarmupDiscoveryService extends AbstractDiscoveryService
|
||||
|
||||
@Override
|
||||
public void setThingHandler(@Nullable final ThingHandler handler) {
|
||||
if (handler instanceof MyWarmupAccountHandler) {
|
||||
bridgeHandler = (MyWarmupAccountHandler) handler;
|
||||
if (handler instanceof MyWarmupAccountHandler accountHandler) {
|
||||
bridgeHandler = accountHandler;
|
||||
bridgeUID = handler.getThing().getUID();
|
||||
} else {
|
||||
bridgeHandler = null;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
package org.openhab.binding.warmup.internal.handler;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -70,7 +70,7 @@ public class MyWarmupAccountHandler extends BaseBridgeHandler {
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(WarmupDiscoveryService.class);
|
||||
return Set.of(WarmupDiscoveryService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -60,11 +60,12 @@ public class RoomHandler extends WarmupThingHandler implements WarmupRefreshList
|
||||
@Override
|
||||
public void handleCommand(ChannelUID channelUID, Command command) {
|
||||
super.handleCommand(channelUID, command);
|
||||
if (CHANNEL_TARGET_TEMPERATURE.equals(channelUID.getId()) && command instanceof QuantityType<?>) {
|
||||
setOverride((QuantityType<?>) command);
|
||||
if (CHANNEL_TARGET_TEMPERATURE.equals(channelUID.getId())
|
||||
&& command instanceof QuantityType<?> quantityCommand) {
|
||||
setOverride(quantityCommand);
|
||||
}
|
||||
if (CHANNEL_FROST_PROTECTION_MODE.equals(channelUID.getId()) && command instanceof OnOffType) {
|
||||
toggleFrostProtectionMode((OnOffType) command);
|
||||
if (CHANNEL_FROST_PROTECTION_MODE.equals(channelUID.getId()) && command instanceof OnOffType onOffCommand) {
|
||||
toggleFrostProtectionMode(onOffCommand);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user