Class DualPathPredicates
Object
org.anchoranalysis.io.input.path.matcher.DualPathPredicates
public class DualPathPredicates extends Object
A
Predicate<Path for both a file and a directory.- Author:
- Owen Feehan
-
Constructor Summary
Constructors Constructor Description DualPathPredicates(CheckedPredicate<Path,IOException> file, CheckedPredicate<Path,IOException> directory) -
Method Summary
Modifier and Type Method Description voidconsumeMatchingFiles(List<Path> paths, Consumer<File> consumerMatching)Calls aConsumeron any path that matches the predicatefile.CheckedPredicate<Path,IOException>getDirectory()Only accepts any containing directories where the predicate returns truebooleanmatchFile(Path path)Whether the path to a particular file matches the predicatefile?List<Path>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)
-
-
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 FindFilesExceptionCalls 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
-