Skip to content

Instantly share code, notes, and snippets.

@cajar1988
Created October 30, 2015 18:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cajar1988/1f3ee90af423d29754dc to your computer and use it in GitHub Desktop.
public void notifyPersonsWithHobby_jdk8(NotificationService notificationService) {
fetchAll().stream()
.filter(person -> person.getHobby() != null)
.forEach(person -> notificationService.sendInformation(person.getHobby()));
}
public void notifyPersonsWithHobby_javaslang(NotificationService notificationService) {
ofAll(fetchAll()).forEach(person -> Option.of(person.getHobby())
.forEach(hobby -> notificationService.sendInformation(hobby))
);
}
public void notifyPersonsWithHobby_javaslang_mr(NotificationService notificationService) {
ofAll(fetchAll()).forEach(person -> Option.of(person.getHobby())
.forEach(notificationService::sendInformation)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment