fix nullpointer exception check date garden schedule

This commit is contained in:
giavaphi 2022-11-28 12:38:29 +01:00
parent 2452e42b72
commit ec42a6e75a
1 changed files with 8 additions and 6 deletions

View File

@ -147,12 +147,14 @@ public class GardenSchedule {
final int finalI = i; final int finalI = i;
weekTasks.forEach(task -> { weekTasks.forEach(task -> {
LocalDate checkDate = task.getNextExecution(); LocalDate checkDate = task.getNextExecution();
if (checkDate != null) {
do { do {
if (date.equals(checkDate) && !date.isAfter(task.getEndDate().orElse(LocalDate.MIN))) { if (date.equals(checkDate) && !date.isAfter(task.getEndDate().orElse(LocalDate.MIN))) {
dayTaskList.get(finalI).add(task); dayTaskList.get(finalI).add(task);
} }
checkDate = checkDate.plusDays(task.getInterval().orElse(0)); checkDate = checkDate.plusDays(task.getInterval().orElse(0));
} while (!(task.getInterval().orElse(0) == 0) && checkDate.isBefore(LocalDate.now().plusDays(listLength))); } while (!(task.getInterval().orElse(0) == 0) && checkDate.isBefore(LocalDate.now().plusDays(listLength)));
}
}); });
} }
return dayTaskList; return dayTaskList;