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'");
|
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
|
@Override
|
||||||
public List<TimeSlot> findGapsFitting(Duration duration) {
|
public List<TimeSlot> findGapsFitting(Duration duration) {
|
||||||
// TODO Auto-generated method stub
|
return new CustomListToJavaBinding<>(
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'findGapsFitting'");
|
traverseGapsFitting(duration, new CustomLinkedListImpl<>(), null, timeline.iterator()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user