impl: ldp find gaps fitting
This commit is contained in:
@@ -89,10 +89,32 @@ public class LocalDayPlanImpl implements LocalDayPlan {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findMatchingFreeSlotsOfDuration'");
|
||||
}
|
||||
|
||||
private CustomLinkedList<TimeSlot> traverseGapsFitting(Duration toFind, CustomLinkedList<TimeSlot> goodSlots,
|
||||
Instant startOfBefore, Iterator<Appointment> iterator) {
|
||||
|
||||
boolean hasNext = iterator.hasNext();
|
||||
|
||||
Appointment nextAppointment = hasNext ? iterator.next() : null;
|
||||
|
||||
TimeSlot possibleFittingSlot = new TimeSlotImpl(hasNext ? nextAppointment.end() : startOfDay(),
|
||||
startOfBefore == null ? endOfDay() : startOfBefore);
|
||||
|
||||
if (possibleFittingSlot.fits(toFind)) {
|
||||
goodSlots.add(possibleFittingSlot);
|
||||
}
|
||||
|
||||
if (!hasNext) {
|
||||
return goodSlots;
|
||||
}
|
||||
|
||||
return traverseGapsFitting(toFind, goodSlots, nextAppointment.start(), iterator);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TimeSlot> findGapsFitting(Duration duration) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findGapsFitting'");
|
||||
return new CustomListToJavaBinding<>(
|
||||
traverseGapsFitting(duration, new CustomLinkedListImpl<>(), null, timeline.iterator()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user