JavaDoc for Stream.collect()表示它返回the result of the reduction.这并不告诉我这样的代码是否可以为filteredList返回null:
List<String> filteredList = inputList.stream().
filter(c -> c.getSomeBoolean()).
flatMap(c -> {
List<String> l = new ArrayList<String>();
l.add(c.getSomething());
l.add(c.getSomethingElse());
return l.stream();
}).
filter(s -> StringUtils.isNotBlank(s)).
collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
我希望如果它可以返回null然后它将返回Optional,但它也没有说.
是否记录Stream.collect()是否可以返回null?