Class DualPathPredicates

Object
DualPathPredicates

public class DualPathPredicates extends Object
A Predicate<Path for both a file and a directory.
Author:
Owen Feehan
  • Constructor Details

    • DualPathPredicates

      public DualPathPredicates(CheckedPredicate<Path,IOException> file, CheckedPredicate<Path,IOException> directory)
      Creates a new DualPathPredicates instance.
      Parameters:
      file - Only accepts files where the predicate returns true
      directory - Only accepts any containing directories where the predicate returns true
  • Method Details

    • matchFile

      public boolean matchFile(Path path) throws IOException
      Whether the path to a particular file matches the predicate file?
      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 a Consumer on any path that matches the predicate file.
      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

      public List<Path> matchingLeafDirectories(List<Path> leafDirectories) throws FindFilesException
      Creates a new list of paths to leaf-directories that match the predicate directory.
      Parameters:
      leafDirectories - the paths to the directories to consider.
      Returns:
      a newly created list containing the elements of leafDirectories that match directory.
      Throws:
      FindFilesException - if an error occurs testing a path.
    • getDirectory

      public CheckedPredicate<Path,IOException> getDirectory()
      Only accepts any containing directories where the predicate returns true