So:
- you have an array which you want to stream:
Arrays.stream(q)
- then you want to map each string to a set of node:
.map(InMemoryGraph::getAllPredicates)
- and collect those sets in a set:
.collect(toSet());
in one go:
Set<Set<Node>> sets = Arrays.stream(q) //a Stream<String>
.map(InMemoryGraph::getAllPredicates) // a Stream<Set<Node>>
.collect(toSet()); // a Set<Set<Node>>
Note: you need a static import of Collectors.toSet
.