void (@NotNull String binaryPath, @NotNull Map<LibraryPathType, List<String>> collect, boolean sourceResolved, boolean docResolved) { final Path file = Paths.get(binaryPath); Path binaryFileParent = file.getParent(); if (!Files.isDirectory(binaryFileParent)) return; try (Stream<Path> list = Files.list(binaryFileParent)) { for (Iterator<Path> it = list.iterator(); it.hasNext(); ) { Path p = it.next(); if (!Files.isRegularFile(p)) continue; String name = p.getFileName().toString(); if (!sourceResolved && name.endsWith(SOURCE_JAR_SUFFIX)) { collect.computeIfAbsent(LibraryPathType.SOURCE, type -> new SmartList<>()).add(p.toFile().getPath()); sourceResolved = true; } else if (!docResolved && name.endsWith(JAVADOC_JAR_SUFFIX)) { collect.computeIfAbsent(LibraryPathType.DOC, type -> new SmartList<>()).add(p.toFile().getPath()); docResolved = true; } if (sourceResolved && docResolved) { return; } } } catch (IOException e) { LOG.debug(e); } }