FilterFolders - ViiSE/papka GitHub Wiki

FilterFolders

FilterFolders<T> - filter by folders.

Constructors

public FilterFolders(Find<List<Folder<T>>, String> findFolders, String pattern)

Find<List<Folder<T>>, String> findFolders - find of folders.
String pattern - filter criteria.

Example

List<String> rootFiles = new ArrayList<>();
rootFiles.add("root1.png");
rootFiles.add("root2.pdf");

List<String> child1Files = new ArrayList<>();
child1Files.add("child1.txt");

List<String> child2Files = new ArrayList<>();
child2Files.add("child2.txt");

List<String> child3Files = new ArrayList<>();
child3Files.add("music1.mp3");
child3Files.add("music2.mp3");

List<String> child21Files = new ArrayList<>();
child21Files.add("child21.txt");

Folder<String> root = new FolderPure<>(
        new NameFolderRoot(),
        rootFiles,
        new FolderPure<>(
                "/child1",
                child1Files),
        new FolderPure<>(
                "/child2",
                child2Files,
                new FolderPure<>(
                        "/child2/child21",
                        child21Files)),
        new FolderPure<>(
                "/music",
                child3Files));

Filter<List<Folder<String>>> filter = new FilterFolders<>(
        new FindByStartWith<>(
                new FindFoldersByRegex<>(
                        root,
                        false)),
        "child");
List<Folder<String>> folders = filter.apply();
folders.forEach(folder -> System.out.println(folder.fullName()));
Output:

/child1
/child2
/child2/child21

Links

Filter - implementable interface.

Find - constructor argument.

⚠️ **GitHub.com Fallback** ⚠️