List<Interval> validPeriods = realAvailability.getValidPeriods();
if (validPeriods.isEmpty()) {
return new ThereAreNoValidPeriods(calendar, availability);
}
Interval last = getLast(validPeriods);
Interval first = validPeriods.get(0);
final boolean isOpenEnded = last.getEnd().equals(EndOfTime.create())
|| first.getStart().equals(StartOfTime.create());
if (isOpenEnded) {
return new CapacityAvailable();
}
return thereIsCapacityOn(calendar, effortToAllocate, resourcesPerDay,
validPeriods);