Last active
March 14, 2020 09:03
-
-
Save ashkrit/c90dfbe0e27539326879cf30f5b41b65 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Address has priority , first home and then Office | |
Optional<String> address = Stream | |
.of(person.getHome().map(Home::getAddress), person.getOffice().map(Office::getAddress)) | |
.filter(Optional::isPresent) | |
.map(Optional::get) | |
.findFirst(); | |
address | |
.ifPresent(add -> System.out.println("Contacting at address " + add)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment