void (@NotNull FileGeneratedEvent event) { Collection<Pair<String, String>> paths = event.getPaths(); FileSystem fs = FileSystems.getDefault(); if (paths.size() == 1) { deleteFiles(paths.iterator().next().first, fs); return; } Set<String> outputs = new HashSet<>(); for (Pair<String, String> pair : paths) { String root = pair.getFirst(); if (outputs.add(root)) { deleteFiles(root, fs); } } }