// Path: src/main/java/com/poolik/classfinder/io/visitor/SuffixFileVisitor.java
// public class SuffixFileVisitor extends SimpleFileVisitor<Path> {
//   private final String suffix;
//   private final Collection<File> files = new ArrayList<>();
// 
//   public SuffixFileVisitor(String suffix) {
//     this.suffix = suffix;
//   }
// 
//   public Collection<File> getFiles() {
//     return files;
//   }
// 
//   @Override
//   public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
//     if (file.getFileName().toString().endsWith(suffix)) files.add(file.toFile());
//     return FileVisitResult.CONTINUE;
//   }
// }
// 
// Path: src/main/java/com/poolik/classfinder/io/visitor/CopyDirVisitor.java
// public class CopyDirVisitor extends SimpleFileVisitor<Path> {
// 
//   private final Path fromPath;
//   private final Path toPath;
//   private final StandardCopyOption copyOption;
//   private final Predicate<Path> copyPredicate;
// 
//   public CopyDirVisitor(Path fromPath, Path toPath, Predicate<Path> predicate) {
//     this(fromPath, toPath, StandardCopyOption.REPLACE_EXISTING, predicate);
//   }
// 
//   public CopyDirVisitor(Path fromPath, Path toPath, StandardCopyOption copyOption, Predicate<Path> predicate) {
//     this.fromPath = fromPath;
//     this.toPath = toPath;
//     this.copyOption = copyOption;
//     this.copyPredicate = predicate;
//   }
// 
//   @Override
//   public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
// 
//     Path targetPath = toPath.resolve(fromPath.relativize(dir));
//     if (!Files.exists(targetPath)) {
//       Files.createDirectories(targetPath);
//     }
//     return FileVisitResult.CONTINUE;
//   }
// 
//   @Override
//   public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
//     if (copyPredicate.apply(file))
//       Files.copy(file, toPath.resolve(fromPath.relativize(file)), copyOption);
//     return FileVisitResult.CONTINUE;
//   }
// }
// 
// Path: src/main/java/com/poolik/classfinder/io/visitor/DeleteDirVisitor.java
// public class DeleteDirVisitor extends SimpleFileVisitor<Path> {
// 
//   @Override
//   public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
//     Files.delete(file);
//     return FileVisitResult.CONTINUE;
//   }
// 
//   @Override
//   public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
//     if (exc == null) {
//       Files.delete(dir);
//       return FileVisitResult.CONTINUE;
//     }
//     throw exc;
//   }
// }


import com.poolik.classfinder.io.visitor.SuffixFileVisitor;
import com.poolik.classfinder.io.visitor.CopyDirVisitor;
import com.poolik.classfinder.io.visitor.DeleteDirVisitor;
import java.io.File;
import java.io.IOException;
import java.nio.file.*;
import java.util.Collection;
import java.util.EnumSet;
import java.util.Objects;
package com.poolik.classfinder.io;



public class DirUtils {

  private DirUtils() {}

  public static void deleteIfExists(Path path) throws IOException {
    if (Files.exists(path)) {
      validate(path);
// Path: src/main/java/com/poolik/classfinder/io/visitor/SuffixFileVisitor.java
// public class SuffixFileVisitor extends SimpleFileVisitor<Path> {
//   private final String suffix;
//   private final Collection<File> files = new ArrayList<>();
// 
//   public SuffixFileVisitor(String suffix) {
//     this.suffix = suffix;
//   }
// 
//   public Collection<File> getFiles() {
//     return files;
//   }
// 
//   @Override
//   public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
//     if (file.getFileName().toString().endsWith(suffix)) files.add(file.toFile());
//     return FileVisitResult.CONTINUE;
//   }
// }
// 
// Path: src/main/java/com/poolik/classfinder/io/visitor/CopyDirVisitor.java
// public class CopyDirVisitor extends SimpleFileVisitor<Path> {
// 
//   private final Path fromPath;
//   private final Path toPath;
//   private final StandardCopyOption copyOption;
//   private final Predicate<Path> copyPredicate;
// 
//   public CopyDirVisitor(Path fromPath, Path toPath, Predicate<Path> predicate) {
//     this(fromPath, toPath, StandardCopyOption.REPLACE_EXISTING, predicate);
//   }
// 
//   public CopyDirVisitor(Path fromPath, Path toPath, StandardCopyOption copyOption, Predicate<Path> predicate) {
//     this.fromPath = fromPath;
//     this.toPath = toPath;
//     this.copyOption = copyOption;
//     this.copyPredicate = predicate;
//   }
// 
//   @Override
//   public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
// 
//     Path targetPath = toPath.resolve(fromPath.relativize(dir));
//     if (!Files.exists(targetPath)) {
//       Files.createDirectories(targetPath);
//     }
//     return FileVisitResult.CONTINUE;
//   }
// 
//   @Override
//   public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
//     if (copyPredicate.apply(file))
//       Files.copy(file, toPath.resolve(fromPath.relativize(file)), copyOption);
//     return FileVisitResult.CONTINUE;
//   }
// }
// 
// Path: src/main/java/com/poolik/classfinder/io/visitor/DeleteDirVisitor.java
// public class DeleteDirVisitor extends SimpleFileVisitor<Path> {
// 
//   @Override
//   public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
//     Files.delete(file);
//     return FileVisitResult.CONTINUE;
//   }
// 
//   @Override
//   public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
//     if (exc == null) {
//       Files.delete(dir);
//       return FileVisitResult.CONTINUE;
//     }
//     throw exc;
//   }
// }


// Path: src/main/java/com/poolik/classfinder/io/DirUtils.java
import com.poolik.classfinder.io.visitor.SuffixFileVisitor;
import com.poolik.classfinder.io.visitor.CopyDirVisitor;
import com.poolik.classfinder.io.visitor.DeleteDirVisitor;
import java.io.File;
import java.io.IOException;
import java.nio.file.*;
import java.util.Collection;
import java.util.EnumSet;
import java.util.Objects;

package com.poolik.classfinder.io;



public class DirUtils {

  private DirUtils() {}

  public static void deleteIfExists(Path path) throws IOException {
    if (Files.exists(path)) {
      validate(path);
      Files.walkFileTree(path, new DeleteDirVisitor());