{
final OrFileFilter alwaysSkipFiles = new OrFileFilter();
final Collection<Pattern> alwaysSkipPatterns = new HashSet<Pattern>();
final Map<IOFileFilter, Pattern> sometimesSkipPatterns = new HashMap<IOFileFilter, Pattern>();
for( final SkipExpressionSpec spec: toSkip ) {
final IOFileFilter ff = spec.getFileFilter();
final Pattern ef = spec.getExpressionFilter();
if(ff == null) {
if(ef == null) {
return EMPTY_ITER; //both exprs null == skip everything.
}
else {
alwaysSkipPatterns.add(ef);
}
}
else if(ef == null) {
alwaysSkipFiles.addFileFilter(ff);
}
else {
sometimesSkipPatterns.put(ff, ef);
}
}
final IOFileFilter compositeFilter
= new AndFileFilter(fileFilter,
new NotFileFilter(alwaysSkipFiles));
final Iterator<?> baseIter
= FileUtils.iterateFiles(baseDir, compositeFilter, dirFilter);
return new MultiFileELExpressionIterator(asFileIter(baseIter), alwaysSkipPatterns, sometimesSkipPatterns);