DEV Community

Discussion on: The joy of streams

Collapse
 
alainvanhout profile image
Alain Van Hout

I tend to write this in the following way, as it optimizes for clarity:

Set<Event> events = requirements.stream()
   .map(Requirement::getEvent)
   .filter(Objects::nonNonNull)
   .collect(Collectors.toSet());