Created
August 17, 2021 05:42
-
-
Save muthuishere/8aa8115ce18b2faa1329044ffd04f9a9 to your computer and use it in GitHub Desktop.
Default value
This file contains 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
results= Try.from(()->newsService.downloadFromNyTimes(topic)) | |
.or(()->newsService.downloadFromHerald(topic)) | |
.or(()->newsService.downloadFromSun(topic)) | |
.get(); | |
// since the for the above case it will be null | |
// if you would like to get default value | |
results= Try.from(()->newsService.downloadFromNyTimes(topic)) | |
.or(()->newsService.downloadFromHerald(topic)) | |
.or(()->newsService.downloadFromSun(topic)) | |
.orElseGet(Arrays.asList("Default News for topic x","Default News for topic Y")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment