/** * Return a folder object that's used to search a recursive * directory containing the complete works of William Shakespeare. */ public static Folder getRootFolder(String rootFolderName, boolean parallel) throws URISyntaxException, IOException { return Folder .fromDirectory(new File(ClassLoader .getSystemResource(rootFolderName) .toURI()).toPath(), parallel); }
/** * Return a folder object that's used to search a recursive * directory containing the complete works of William Shakespeare. */ private static Folder getRootFolder(String rootFolderName, boolean parallel) throws URISyntaxException, IOException { return Folder .fromDirectory(new File(ClassLoader .getSystemResource(rootFolderName) .toURI()).toPath(), parallel); }
/** * A function that folds a Path into the mutable result container. * * @return a function which folds a Path into a mutable result container */ @Override public BiConsumer<Folder, Path> accumulator() { Function<Path, Folder> getFolders = ExceptionUtils.rethrowFunction(file -> Folder.fromDirectory(file, mParallel)); Function<Path, Document> getDocuments = ExceptionUtils.rethrowFunction(Document::fromPath); return (Folder folder, Path entry) -> { if (Files.isDirectory(entry)) folder.getSubFolders().add(getFolders.apply(entry)); else folder.getDocuments().add(getDocuments.apply(entry)); }; }
/** * A function that folds a Path into the mutable result container. * * @return a function which folds a Path into a mutable result container */ @Override public BiConsumer<Folder, Path> accumulator() { Function<Path, Folder> getFolders = ExceptionUtils.rethrowFunction(file -> Folder.fromDirectory(file, mParallel)); Function<Path, Document> getDocuments = ExceptionUtils.rethrowFunction(Document::fromPath); return (Folder folder, Path entry) -> { if (Files.isDirectory(entry)) folder.getSubFolders().add(getFolders.apply(entry)); else folder.getDocuments().add(getDocuments.apply(entry)); }; }