cucumber.runtime.io.FileResourceIterator Maven / Gradle / Ivy
package cucumber.runtime.io;
import java.io.File;
import java.io.FileFilter;
import java.util.Iterator;
import static cucumber.runtime.io.ClasspathIterable.hasSuffix;
import static java.util.Arrays.asList;
public class FileResourceIterator implements Iterator {
private final FlatteningIterator flatteningIterator = new FlatteningIterator();
public FileResourceIterator(File root, File file, final String suffix) {
FileFilter filter = new FileFilter() {
@Override
public boolean accept(File file) {
return file.isDirectory() || hasSuffix(suffix, file.getPath());
}
};
flatteningIterator.push(new FileIterator(root, file, filter));
}
@Override
public boolean hasNext() {
return flatteningIterator.hasNext();
}
@Override
public Resource next() {
return (Resource) flatteningIterator.next();
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
/**
* Iterator to iterate over all the files contained in a directory. It returns
* a File object for non directories or a new FileIterator obejct for directories.
*/
private static class FileIterator implements Iterator
© 2015 - 2024 Weber Informatics LLC | Privacy Policy