* @return
*/
private static List<Gap> splitIntoGapsSatisfyingCriteria(Resource resource,
Set<Criterion> criteria, DateAndHour gapStartTime,
DateAndHour gapEndTime) {
AvailabilityTimeLine criterionsAvailability = AvailabilityCalculator
.getCriterionsAvailabilityFor(criteria, resource);
if (gapStartTime != null) {
criterionsAvailability.invalidUntil(gapStartTime.getDate());
}
if (gapEndTime != null) {
criterionsAvailability.invalidFrom(gapEndTime.getDate());
}
List<Interval> validPeriods = criterionsAvailability.getValidPeriods();
List<Gap> result = new ArrayList<Gap>();
for (Interval each : validPeriods) {
result.add(createGap(resource, each, gapStartTime, gapEndTime));
}
return result;