Created
February 14, 2019 15:09
-
-
Save bryanmaina/ff1bd503d5cfdab1976cf4583a6bebfa to your computer and use it in GitHub Desktop.
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
public final class StreamHelpers { | |
public static <T> Consumer<T> branch(Predicate<? super T> test, | |
Consumer<? super T> t, | |
Consumer<? super T> f) { | |
return o -> { | |
if (test.test(o)) t.accept(o); | |
else f.accept(o); | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment