Skip to content

Instantly share code, notes, and snippets.

@iaintshine
Created September 15, 2017 21:15
Show Gist options
  • Save iaintshine/6be385eedc153ddd29ba3d7dbc238273 to your computer and use it in GitHub Desktop.
Save iaintshine/6be385eedc153ddd29ba3d7dbc238273 to your computer and use it in GitHub Desktop.
coalesce with functional interface
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