boolean (@Nullable String directory) { if (directory == null) return false; try { Path path = Path.of(directory); return path.isAbsolute() && Files.isDirectory(path); } catch (InvalidPathException e) { return false; } }