Java 17 features (H-M) (#15520)
- 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:
@@ -65,8 +65,8 @@ public class LinkyCommandExtension extends AbstractConsoleCommandExtension imple
|
||||
LinkyHandler handler = null;
|
||||
if (thing != null) {
|
||||
thingHandler = thing.getHandler();
|
||||
if (thingHandler instanceof LinkyHandler) {
|
||||
handler = (LinkyHandler) thingHandler;
|
||||
if (thingHandler instanceof LinkyHandler linkyHandler) {
|
||||
handler = linkyHandler;
|
||||
}
|
||||
}
|
||||
if (thing == null) {
|
||||
|
||||
@@ -30,7 +30,7 @@ public class AuthData {
|
||||
public @Nullable Object value;
|
||||
|
||||
public @Nullable String valueAsString() {
|
||||
return (value instanceof String) ? (String) value : null;
|
||||
return (value instanceof String stringValue) ? stringValue : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -472,25 +472,25 @@ public class LinkyHandler extends BaseThingHandler {
|
||||
}
|
||||
|
||||
private void checkData(Consumption consumption) throws LinkyException {
|
||||
if (consumption.aggregats.days.periodes.size() == 0) {
|
||||
if (consumption.aggregats.days.periodes.isEmpty()) {
|
||||
throw new LinkyException("Invalid consumptions data: no day period");
|
||||
}
|
||||
if (consumption.aggregats.days.periodes.size() != consumption.aggregats.days.datas.size()) {
|
||||
throw new LinkyException("Invalid consumptions data: not any data for each day period");
|
||||
}
|
||||
if (consumption.aggregats.weeks.periodes.size() == 0) {
|
||||
if (consumption.aggregats.weeks.periodes.isEmpty()) {
|
||||
throw new LinkyException("Invalid consumptions data: no week period");
|
||||
}
|
||||
if (consumption.aggregats.weeks.periodes.size() != consumption.aggregats.weeks.datas.size()) {
|
||||
throw new LinkyException("Invalid consumptions data: not any data for each week period");
|
||||
}
|
||||
if (consumption.aggregats.months.periodes.size() == 0) {
|
||||
if (consumption.aggregats.months.periodes.isEmpty()) {
|
||||
throw new LinkyException("Invalid consumptions data: no month period");
|
||||
}
|
||||
if (consumption.aggregats.months.periodes.size() != consumption.aggregats.months.datas.size()) {
|
||||
throw new LinkyException("Invalid consumptions data: not any data for each month period");
|
||||
}
|
||||
if (consumption.aggregats.years.periodes.size() == 0) {
|
||||
if (consumption.aggregats.years.periodes.isEmpty()) {
|
||||
throw new LinkyException("Invalid consumptions data: no year period");
|
||||
}
|
||||
if (consumption.aggregats.years.periodes.size() != consumption.aggregats.years.datas.size()) {
|
||||
@@ -501,13 +501,13 @@ public class LinkyHandler extends BaseThingHandler {
|
||||
private boolean isDataFirstDayAvailable(Consumption consumption) {
|
||||
Aggregate days = consumption.aggregats.days;
|
||||
logData(days, "First day", false, DateTimeFormatter.ISO_LOCAL_DATE, Target.FIRST);
|
||||
return days.datas != null && days.datas.size() > 0 && !days.datas.get(0).isNaN();
|
||||
return days.datas != null && !days.datas.isEmpty() && !days.datas.get(0).isNaN();
|
||||
}
|
||||
|
||||
private boolean isDataLastDayAvailable(Consumption consumption) {
|
||||
Aggregate days = consumption.aggregats.days;
|
||||
logData(days, "Last day", false, DateTimeFormatter.ISO_LOCAL_DATE, Target.LAST);
|
||||
return days.datas != null && days.datas.size() > 0 && !days.datas.get(days.datas.size() - 1).isNaN();
|
||||
return days.datas != null && !days.datas.isEmpty() && !days.datas.get(days.datas.size() - 1).isNaN();
|
||||
}
|
||||
|
||||
private void logData(Aggregate aggregate, String title, boolean withDateFin, DateTimeFormatter dateTimeFormatter,
|
||||
|
||||
Reference in New Issue
Block a user