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:
@@ -64,12 +64,12 @@ public enum Pollutant {
|
||||
new ConcentrationRange(205, 404, TWO_HUNDRED), new ConcentrationRange(405, 504, THREE_HUNDRED),
|
||||
new ConcentrationRange(505, 604, FOUR_HUNDRED));
|
||||
|
||||
public static enum SensitiveGroup {
|
||||
public enum SensitiveGroup {
|
||||
RESPIRATORY,
|
||||
HEART,
|
||||
ELDERLY,
|
||||
CHILDREN,
|
||||
ASTHMA;
|
||||
ASTHMA
|
||||
}
|
||||
|
||||
public final Set<SensitiveGroup> sensitiveGroups;
|
||||
|
||||
@@ -22,11 +22,11 @@ import com.google.gson.annotations.SerializedName;
|
||||
* @author Gaël L'hopital - Initial contribution
|
||||
*/
|
||||
public class ResponseRoot {
|
||||
public static enum ResponseStatus {
|
||||
public enum ResponseStatus {
|
||||
@SerializedName("error")
|
||||
ERROR,
|
||||
@SerializedName("ok")
|
||||
OK;
|
||||
OK
|
||||
}
|
||||
|
||||
protected ResponseStatus status = ResponseStatus.OK;
|
||||
|
||||
@@ -28,8 +28,7 @@ public class SensitiveGroupConfiguration {
|
||||
|
||||
public @Nullable SensitiveGroup asSensitiveGroup() {
|
||||
try {
|
||||
SensitiveGroup value = SensitiveGroup.valueOf(group);
|
||||
return value;
|
||||
return SensitiveGroup.valueOf(group);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ package org.openhab.binding.airquality.internal.discovery;
|
||||
import static org.openhab.binding.airquality.internal.AirQualityBindingConstants.*;
|
||||
import static org.openhab.binding.airquality.internal.config.AirQualityConfiguration.LOCATION;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
@@ -43,7 +42,7 @@ import org.slf4j.LoggerFactory;
|
||||
@NonNullByDefault
|
||||
public class AirQualityDiscoveryService extends AbstractDiscoveryService implements ThingHandlerService {
|
||||
private static final int DISCOVER_TIMEOUT_SECONDS = 2;
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_STATION);
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_STATION);
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(AirQualityDiscoveryService.class);
|
||||
|
||||
@@ -59,9 +58,8 @@ public class AirQualityDiscoveryService extends AbstractDiscoveryService impleme
|
||||
|
||||
@Override
|
||||
public void setThingHandler(@Nullable ThingHandler handler) {
|
||||
if (handler instanceof AirQualityBridgeHandler) {
|
||||
final AirQualityBridgeHandler bridgeHandler = (AirQualityBridgeHandler) handler;
|
||||
this.bridgeHandler = bridgeHandler;
|
||||
if (handler instanceof AirQualityBridgeHandler bridgeHandlerInstance) {
|
||||
this.bridgeHandler = bridgeHandlerInstance;
|
||||
this.locationProvider = bridgeHandler.getLocationProvider();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user