Java 17 features (N-S) (#15565)

- 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-13 08:03:31 +02:00
committed by GitHub
parent 641b482551
commit ab58f4ffb4
471 changed files with 1624 additions and 1868 deletions

View File

@@ -120,7 +120,7 @@ public class AccountHandler extends BaseBridgeHandler {
int expiresIn = Integer.parseInt(responseJson.get("expires_in").toString());
setTokenExpiryDate(TimeUnit.SECONDS.toNanos(expiresIn));
setAuthToken(responseJson.get(AUTH_TOKEN).toString().replaceAll("\"", ""));
setAuthToken(responseJson.get(AUTH_TOKEN).toString().replace("\"", ""));
updateStatus(ThingStatus.ONLINE);
return;

View File

@@ -12,7 +12,6 @@
*/
package org.openhab.binding.pixometer.internal;
import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -40,7 +39,7 @@ public class PixometerBindingConstants {
public static final ThingTypeUID THING_TYPE_GASMETER = new ThingTypeUID(BINDING_ID, "gasmeter");
public static final ThingTypeUID THING_TYPE_WATERMETER = new ThingTypeUID(BINDING_ID, "watermeter");
public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Collections.singleton(BRIDGE_THING_TYPE);
public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Set.of(BRIDGE_THING_TYPE);
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Stream
.of(THING_TYPE_ENERGYMETER, THING_TYPE_GASMETER, THING_TYPE_WATERMETER).collect(Collectors.toSet());

View File

@@ -96,7 +96,7 @@ public class CustomReadingInstanceDeserializer implements JsonDeserializer<Readi
* @return The wanted string without unnecessary quotation marks
*/
private String getStringFromJson(JsonObject data, String key) {
return data.get(key).toString().replaceAll("\"", "");
return data.get(key).toString().replace("\"", "");
}
/**
@@ -104,6 +104,6 @@ public class CustomReadingInstanceDeserializer implements JsonDeserializer<Readi
* @return returns true if null values have been found, false otherwise
*/
private boolean checkStringForNullValues(String s) {
return (s == null || s.isEmpty() || s.equals("null"));
return (s == null || s.isEmpty() || "null".equals(s));
}
}