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:
Holger Friedrich
2023-09-05 22:30:16 +02:00
committed by GitHub
parent a0dc5c05f2
commit cf10b3e9c7
486 changed files with 2053 additions and 1955 deletions

View File

@@ -27,6 +27,7 @@ public class AwattarBestpriceConfiguration {
public int length;
public boolean consecutive;
@Override
public String toString() {
return String.format("{ s: %d, d: %d, l: %d, c: %b )", rangeStart, rangeDuration, length, consecutive);
}

View File

@@ -66,11 +66,13 @@ public class AwattarConsecutiveBestPriceResult extends AwattarBestPriceResult {
return priceSum;
}
@Override
public String toString() {
return String.format("{%s, %s, %.2f}", formatDate(getStart(), zoneId), formatDate(getEnd(), zoneId),
priceSum / length);
}
@Override
public String getHours() {
return hours;
}

View File

@@ -52,6 +52,7 @@ public class AwattarNonConsecutiveBestPriceResult extends AwattarBestPriceResult
return members.stream().anyMatch(x -> x.contains(Instant.now().toEpochMilli()));
}
@Override
public String toString() {
return String.format("NonConsecutiveBestpriceResult with %s", members.toString());
}
@@ -67,6 +68,7 @@ public class AwattarNonConsecutiveBestPriceResult extends AwattarBestPriceResult
}
}
@Override
public String getHours() {
boolean second = false;
sort();

View File

@@ -50,6 +50,7 @@ public class AwattarPrice implements Comparable<AwattarPrice> {
return price;
}
@Override
public String toString() {
return String.format("(%1$tF %1$tR - %2$tR: %3$.3f)", startTimestamp, endTimestamp, getPrice());
}

View File

@@ -40,9 +40,7 @@ public class AwattarUtil {
int offset = min % mod;
offset = offset == 0 ? mod : offset;
dt = dt.plusMinutes(offset);
long result = dt.toInstant().toEpochMilli() - now;
return result;
return dt.toInstant().toEpochMilli() - now;
}
public static ZonedDateTime getCalendarForHour(int hour, ZoneId zone) {

View File

@@ -97,6 +97,7 @@ public class AwattarPriceHandler extends BaseThingHandler {
updateStatus(ThingStatus.UNKNOWN);
}
@Override
public void dispose() {
ScheduledFuture<?> localRefresher = thingRefresher;
if (localRefresher != null) {