sid-srini commented on code in PR #7722:
URL: https://github.com/apache/netbeans/pull/7722#discussion_r1743594266
##########
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:
> Not quite sure about this cascade - is there a reason why this should
improve the behavior?
>
I can change the code to the imperative style using `for` and `if`. The
cascade was not meant for improving behaviour.
> I guess I'd say something like: `return paths.isEmpty() ? null : paths;`
should work well enough? (Using the short-circuit behavior when the value is
`null`, if we didn't want to use that, I would say simply `return paths`.)
>
- I was unsure if returning `null` from the utility method would be frowned
upon here. :)
- The reason for returning `Collections.singleton(paths)` is to be more
performant during the comparison; for the usual scenario i.e. of a single root
path configured.
Please let me know if I should just change it to just `return paths;`
without the `Stream` cascade.
Thanks.
--
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