Created
September 15, 2017 21:15
-
-
Save iaintshine/6be385eedc153ddd29ba3d7dbc238273 to your computer and use it in GitHub Desktop.
coalesce with functional interface
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
private Long coalesce(Map<String, Object> payload, Function<Map<String, Object>, Long>... fs) { | |
return Arrays.stream(fs) | |
.map(f -> f.apply(payload)) | |
.filter(Objects::nonNull) | |
.findFirst() | |
.orElse(null); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment