EntitySearcher.getTypes(individual, ontology)
returns a Stream of OWLClassExpression
.
to print it we do:
EntitySearcher.getTypes(individual, ontology).forEach(System.out::println);
Instead i want to store the output in an OWLClass or a Set of OWLClass to deal with it later. How do i do that?
The Stream operations are confusing me.
Sincere regards
To turn a stream into a set, there's a utility in OWLAPIStreamUtils::asSet(Stream) - this is just a convenience around the standard Collectors class.
To get OWLClass only, you need to filter the types:
Set classes = OWLAPIStreamUtils.asSet( EntitySearcher.getTypes(individual, ontology) .filter(OWLClassExpression::isOWLClass));