Skip to content

Instantly share code, notes, and snippets.

@rnaufal
Created March 6, 2018 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rnaufal/37d27a8901cae1264ca89a250b31109f to your computer and use it in GitHub Desktop.
Save rnaufal/37d27a8901cae1264ca89a250b31109f to your computer and use it in GitHub Desktop.
Collection<Car> markCars = people
.stream()
.filter(person -> "Mark".equals(person.getName()))
.findFirst()
.map(Person::getCars)
.filter(Optional::isPresent)
.map(Optional::get)
.orElse(Collections.emptyList());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment