}
private void updateIntervalIfNeeded(Task task) {
if (registeredFirstTask == false) {
registeredFirstTask = true;
interval = new Interval(startMinusTwoWeeks(task),
endPlusOneMonth(task));
invalidatingChangeHappened();
} else {
LocalDate newStart = interval.getStart();
LocalDate newFinish = interval.getFinish();
boolean changed = false;
if (interval.getStart().compareTo(startMinusTwoWeeks(task)) > 0) {
newStart = startMinusTwoWeeks(task);
changed = true;
}
if (interval.getFinish()
.compareTo(endPlusOneMonth(task)) < 0) {
newFinish = endPlusOneMonth(task);
changed = true;
}
if (changed) {
interval = new Interval(newStart, newFinish);
invalidatingChangeHappened();
}
}
}