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:
@@ -13,7 +13,6 @@
|
||||
package org.openhab.binding.weatherunderground.internal;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -38,7 +37,7 @@ public class WeatherUndergroundBindingConstants {
|
||||
public static final ThingTypeUID THING_TYPE_WEATHER = new ThingTypeUID(BINDING_ID, "weather");
|
||||
public static final ThingTypeUID THING_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, "bridge");
|
||||
|
||||
public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_BRIDGE);
|
||||
public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Set.of(THING_TYPE_BRIDGE);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = new HashSet<>(Arrays.asList(THING_TYPE_WEATHER));
|
||||
|
||||
// Channel configuration Properties
|
||||
|
||||
@@ -15,7 +15,6 @@ package org.openhab.binding.weatherunderground.internal.discovery;
|
||||
import static org.openhab.binding.weatherunderground.internal.WeatherUndergroundBindingConstants.*;
|
||||
import static org.openhab.binding.weatherunderground.internal.config.WeatherUndergroundConfiguration.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -44,7 +43,7 @@ import org.slf4j.LoggerFactory;
|
||||
public class WeatherUndergroundDiscoveryService extends AbstractDiscoveryService {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(WeatherUndergroundDiscoveryService.class);
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_WEATHER);
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_WEATHER);
|
||||
private static final int DISCOVER_TIMEOUT_SECONDS = 2;
|
||||
private static final int LOCATION_CHANGED_CHECK_INTERVAL = 60;
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class WeatherUndergroundBridgeHandler extends BaseBridgeHandler {
|
||||
|
||||
// Check if an api key has been provided during the bridge creation
|
||||
Object configApiKey = config.get(WeatherUndergroundBindingConstants.APIKEY);
|
||||
if (configApiKey == null || !(configApiKey instanceof String) || ((String) configApiKey).trim().isEmpty()) {
|
||||
if (!(configApiKey instanceof String) || ((String) configApiKey).trim().isEmpty()) {
|
||||
logger.debug("Setting thing '{}' to OFFLINE: Parameter 'apikey' must be configured.", getThing().getUID());
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||
"@text/offline.conf-error-missing-apikey");
|
||||
|
||||
@@ -179,7 +179,7 @@ public class WeatherUndergroundJsonCurrent {
|
||||
* @return the current relative humidity or null if not defined
|
||||
*/
|
||||
public Integer getRelativeHumidity() {
|
||||
if (relative_humidity != null && !relative_humidity.isEmpty() && !relative_humidity.equalsIgnoreCase("N/A")) {
|
||||
if (relative_humidity != null && !relative_humidity.isEmpty() && !"N/A".equalsIgnoreCase(relative_humidity)) {
|
||||
return WeatherUndergroundJsonUtils.convertToInteger(relative_humidity.replace("%", ""));
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -90,8 +90,8 @@ public class WeatherUndergroundJsonUtils {
|
||||
}
|
||||
|
||||
private static boolean isValid(String value) {
|
||||
return (value != null) && !value.isEmpty() && !value.equalsIgnoreCase("N/A") && !value.equalsIgnoreCase("NA")
|
||||
&& !value.equals("-") && !value.equals("--");
|
||||
return (value != null) && !value.isEmpty() && !"N/A".equalsIgnoreCase(value) && !"NA".equalsIgnoreCase(value)
|
||||
&& !"-".equals(value) && !"--".equals(value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user