public List<ScheduleEntry> expandSchedule(DateTime dateTime, List<ScheduleEntry> entries) { removeFutureEntries(dateTime, entries); TreeSet<ScheduleEntry> set = new TreeSet<>(entries); for (int i = 0; i < DAYS_AHEAD; i++, dateTime = dateTime.plusDays(1)) { set.add(new ScheduleEntry(dateTime.getMillis())); } return new ArrayList<>(set); }
private void removeFutureEntries(DateTime dateTime, List<ScheduleEntry> entries) { for (Iterator<ScheduleEntry> it = entries.iterator(); it.hasNext(); ) { ScheduleEntry current = it.next(); if (current.getDate() - dateTime.getMillis() >= DateTimeConstants.MILLIS_PER_DAY * 20) it.remove(); } }