8207690: Parsing API for classpath and similar path strings
mark.reinhold at oracle.com
mark.reinhold at oracle.com
Fri Sep 14 22:31:33 UTC 2018
2018/9/13 10:21:26 -0700, roger.riggs at oracle.com:
> Consider:
>
> public class SearchPath {
> public static SearchPath of(String searchPath) {...}
> public static SearchPath of(List<String> elements) {...}
> public Stream<String> stream() {...}
> public List<String> asList() {...}
> public String toString() {...}
> private SearchPath() {};
> }
>
> A SearchPath can be constructed from various forms of search path
> elements and can create other forms as needed.
> As a class it would be extensible and can start small and grow as needed.
>
> Examples:
> List<String> list = SearchPath.of("a:b:c").asList();
>
> Path p = SearchPath.of("x:y:z").stream()
> .filter(Predicate.not(String::isEmpty))
> .map(Path::of)
> .filter(Files::isDirectory)
> .filter(q -> Files.exists(q.resolve("x.jar)))
> .findFirst()
> .orElseThrow();
>
> If that seems like a reasonable base, I (or some other volunteer) can
> flesh it out with the suggestions.
Yes -- this is along the lines of what I was trying to suggest.
Stick to the goal of representing a search path, and leave actual
I/O operations, if any, to the caller.
I think that puts this class squarly in the realm of java.util
rather than java.nio.file.
- Mark
More information about the core-libs-dev
mailing list