public static < T , R1 , R > Optional < R > forEach2 ( Optional < ? extends T > value1 , Function < ? super T , Optional < R1 > > value2 , BiFunction < ? super T , ? super R1 , ? extends R > yieldingFunction ) { return value1 . flatMap ( in -> { Optional < R1 > a = value2 . apply ( in ) ; return a . map ( in2 -> yieldingFunction . apply ( in , in2 ) ) ; } ) ; }
Perform a For Comprehension over a Optional accepting a generating function . This results in a two level nested internal iteration over the provided Optionals .