class FileOperations {

  public static void copy(ImmutableList<Path> sourceFiles, Path destDir) throws IOException {
    for (Path sourceFile : sourceFiles) {
      PathConsumer copyPathConsumer =
          path -> {
            // Creates the same path in the destDir.
            Path destPath = destDir.resolve(sourceFile.getParent().relativize(path));
            if (Files.isDirectory(path)) {
              Files.createDirectories(destPath);
            } else {
              Files.copy(path, destPath);
            }
          };

      if (Files.isDirectory(sourceFile)) {
        new DirectoryWalker(sourceFile).walk(copyPathConsumer);
      } else {
        copyPathConsumer.accept(sourceFile);
      }
    }
  }

  private  FileOperations();

}