mbien commented on code in PR #7722:
URL: https://github.com/apache/netbeans/pull/7722#discussion_r1807917942
##########
ide/projectapi/src/org/netbeans/modules/projectapi/SimpleFileOwnerQueryImplementation.java:
##########
@@ -414,6 +421,18 @@ private static URI goUp(URI u) {
assert u.toString().startsWith(nue.toString()) : "not a parent: " +
nue + " of " + u;
return nue;
}
+
+ private static Set<String> extractFolderPaths(String folders, String
pathSeparator) {
+ Set<String> paths = Arrays.stream(folders.split(pathSeparator))
//NOI18N
+ .filter(s -> !s.trim().isEmpty())
+ .map(f -> FileUtil.toFileObject(FileUtil.normalizeFile(new
File(f))))
+ .filter(Objects::nonNull)
+ .map(FileObject::getPath)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toSet());
+ return paths.isEmpty() ? Collections.emptySet() : paths.size() == 1 ?
Collections.singleton(paths.iterator().next()) : paths;
Review Comment:
just as sidenote: I don't actually mind streams like that, what I do however
is to filter early and to combine filters.
so instead of:
```
map(..).filter(nonNull).map(..).filter(nonNull)...
```
you would get:
```
.filter(foo != null && foo.getOther() != null)
.map(::getOther)
```
this is often easier to read (for java devs) since it is very similar to how
the body of a for-loop would look like.
regarding debugging: NB is lacking good support for stream debugging, but
`peek()` or intermediate temporary cuts with `toList()` to debug through the
stream works just fine in a lot of cases. Sure you have to change the code
slightly before setting a breakpoint but its often not a big deal. (exceptions
do never combine very well with streams though thats when the loops always win)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists