Instantly share code, notes, and snippets.

@cajar1988 /hobby.java Secret
Created Oct 30, 2015

Embed
What would you like to do?
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