Class DualPathPredicates
Object
DualPathPredicates
A
Predicate<Path for both a file and a directory.- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionDualPathPredicates(CheckedPredicate<Path, IOException> file, CheckedPredicate<Path, IOException> directory) Creates a newDualPathPredicatesinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidconsumeMatchingFiles(List<Path> paths, Consumer<File> consumerMatching) Calls aConsumeron any path that matches the predicatefile.Only accepts any containing directories where the predicate returns truebooleanWhether the path to a particular file matches the predicatefile?matchingLeafDirectories(List<Path> leafDirectories) Creates a new list of paths to leaf-directories that match the predicatedirectory.
-
Constructor Details
-
DualPathPredicates
public DualPathPredicates(CheckedPredicate<Path, IOException> file, CheckedPredicate<Path, IOException> directory) Creates a newDualPathPredicatesinstance.- Parameters:
file- Only accepts files where the predicate returns truedirectory- Only accepts any containing directories where the predicate returns true
-
-
Method Details
-
matchFile
Whether the path to a particular file matches the predicatefile?- Parameters:
path- the path.- Returns:
- true if matches the predicate.
- Throws:
IOException- if an error occurs testing the path.
-
consumeMatchingFiles
public void consumeMatchingFiles(List<Path> paths, Consumer<File> consumerMatching) throws FindFilesException Calls aConsumeron any path that matches the predicatefile.- Parameters:
paths- the paths to test.consumerMatching- the consumer to call if a path matches.- Throws:
FindFilesException- if an error occurs testing a path.
-
matchingLeafDirectories
Creates a new list of paths to leaf-directories that match the predicatedirectory.- Parameters:
leafDirectories- the paths to the directories to consider.- Returns:
- a newly created list containing the elements of
leafDirectoriesthat matchdirectory. - Throws:
FindFilesException- if an error occurs testing a path.
-
getDirectory
Only accepts any containing directories where the predicate returns true
-