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:
@@ -41,8 +41,7 @@ public class FreeboxBindingConstants {
|
||||
public static final ThingTypeUID FREEBOX_THING_TYPE_AIRPLAY = new ThingTypeUID(BINDING_ID, "airplay");
|
||||
|
||||
// All supported Bridge types
|
||||
public static final Set<ThingTypeUID> SUPPORTED_BRIDGE_TYPES_UIDS = Collections
|
||||
.singleton(FREEBOX_BRIDGE_TYPE_SERVER);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_BRIDGE_TYPES_UIDS = Set.of(FREEBOX_BRIDGE_TYPE_SERVER);
|
||||
|
||||
// All supported Thing types
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
|
||||
|
||||
@@ -464,8 +464,7 @@ public class FreeboxApiManager {
|
||||
// Parse the full response in case of success
|
||||
T fullResponse = gson.fromJson(jsonResponse, responseClass);
|
||||
fullResponse.evaluate();
|
||||
F result = fullResponse.getResult();
|
||||
return result;
|
||||
return fullResponse.getResult();
|
||||
}
|
||||
|
||||
private String encodeUrl(String url) throws FreeboxException {
|
||||
|
||||
@@ -21,7 +21,7 @@ package org.openhab.binding.freebox.internal.api.model;
|
||||
*/
|
||||
public class FreeboxAirMediaReceiverRequest {
|
||||
|
||||
private static enum MediaAction {
|
||||
private enum MediaAction {
|
||||
START("start"),
|
||||
STOP("stop");
|
||||
|
||||
@@ -36,7 +36,7 @@ public class FreeboxAirMediaReceiverRequest {
|
||||
}
|
||||
}
|
||||
|
||||
private static enum MediaType {
|
||||
private enum MediaType {
|
||||
VIDEO("video"),
|
||||
PHOTO("photo");
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ package org.openhab.binding.freebox.internal.api.model;
|
||||
*/
|
||||
public class FreeboxAuthorizationStatus {
|
||||
|
||||
private static enum AuthorizationStatus {
|
||||
private enum AuthorizationStatus {
|
||||
UNKNOWN("unknown"),
|
||||
PENDING("pending"),
|
||||
TIMEOUT("timeout"),
|
||||
|
||||
@@ -62,8 +62,8 @@ public class FreeboxCommandExtension extends AbstractConsoleCommandExtension imp
|
||||
FreeboxHandler handler = null;
|
||||
if (thing != null) {
|
||||
thingHandler = thing.getHandler();
|
||||
if (thingHandler instanceof FreeboxHandler) {
|
||||
handler = (FreeboxHandler) thingHandler;
|
||||
if (thingHandler instanceof FreeboxHandler freeboxHandler) {
|
||||
handler = freeboxHandler;
|
||||
}
|
||||
}
|
||||
if (thing == null) {
|
||||
|
||||
@@ -79,8 +79,8 @@ public class FreeboxDiscoveryService extends AbstractDiscoveryService
|
||||
|
||||
@Override
|
||||
public void setThingHandler(ThingHandler handler) {
|
||||
if (handler instanceof FreeboxHandler) {
|
||||
bridgeHandler = (FreeboxHandler) handler;
|
||||
if (handler instanceof FreeboxHandler freeboxHandler) {
|
||||
bridgeHandler = freeboxHandler;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ import static org.openhab.binding.freebox.internal.FreeboxBindingConstants.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -92,7 +92,7 @@ public class FreeboxHandler extends BaseBridgeHandler {
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(FreeboxDiscoveryService.class);
|
||||
return Set.of(FreeboxDiscoveryService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -494,8 +494,8 @@ public class FreeboxHandler extends BaseBridgeHandler {
|
||||
continue;
|
||||
}
|
||||
ThingHandler handler = thing.getHandler();
|
||||
if (handler instanceof FreeboxThingHandler) {
|
||||
((FreeboxThingHandler) handler).updateNetInfo(hosts);
|
||||
if (handler instanceof FreeboxThingHandler thingHandler) {
|
||||
thingHandler.updateNetInfo(hosts);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -519,8 +519,8 @@ public class FreeboxHandler extends BaseBridgeHandler {
|
||||
continue;
|
||||
}
|
||||
ThingHandler handler = thing.getHandler();
|
||||
if (handler instanceof FreeboxThingHandler) {
|
||||
((FreeboxThingHandler) handler).updateAirPlayDevice(devices);
|
||||
if (handler instanceof FreeboxThingHandler thingHandler) {
|
||||
thingHandler.updateAirPlayDevice(devices);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,12 +542,10 @@ public class FreeboxHandler extends BaseBridgeHandler {
|
||||
} else if (command instanceof OnOffType) {
|
||||
updateChannelDecimalState(LCDBRIGHTNESS,
|
||||
apiManager.setLcdBrightness((command == OnOffType.ON) ? 100 : 0));
|
||||
} else if (command instanceof DecimalType) {
|
||||
updateChannelDecimalState(LCDBRIGHTNESS,
|
||||
apiManager.setLcdBrightness(((DecimalType) command).intValue()));
|
||||
} else if (command instanceof PercentType) {
|
||||
updateChannelDecimalState(LCDBRIGHTNESS,
|
||||
apiManager.setLcdBrightness(((PercentType) command).intValue()));
|
||||
} else if (command instanceof DecimalType decimalCommand) {
|
||||
updateChannelDecimalState(LCDBRIGHTNESS, apiManager.setLcdBrightness(decimalCommand.intValue()));
|
||||
} else if (command instanceof PercentType percentCommand) {
|
||||
updateChannelDecimalState(LCDBRIGHTNESS, apiManager.setLcdBrightness(percentCommand.intValue()));
|
||||
} else {
|
||||
logger.debug("Thing {}: invalid command {} from channel {}", getThing().getUID(), command,
|
||||
channelUID.getId());
|
||||
@@ -559,9 +557,9 @@ public class FreeboxHandler extends BaseBridgeHandler {
|
||||
}
|
||||
|
||||
private void setOrientation(ChannelUID channelUID, Command command) {
|
||||
if (command instanceof DecimalType) {
|
||||
if (command instanceof DecimalType orientation) {
|
||||
try {
|
||||
FreeboxLcdConfig config = apiManager.setLcdOrientation(((DecimalType) command).intValue());
|
||||
FreeboxLcdConfig config = apiManager.setLcdOrientation(orientation.intValue());
|
||||
updateChannelDecimalState(LCDORIENTATION, config.getOrientation());
|
||||
updateChannelSwitchState(LCDFORCED, config.isOrientationForced());
|
||||
} catch (FreeboxException e) {
|
||||
|
||||
Reference in New Issue
Block a user