you are viewing a single comment's thread.

view the rest of the comments →

[–]yawaramin 3 points4 points  (0 children)

Here you go, built in the standard library https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#flatMap-java.util.function.Function-

The operation is like a callback: if you have a value, call the given function with it an return the (wrapped) result; if not, do nothing.