Skip to content

Instantly share code, notes, and snippets.

@bryanmaina
Created February 14, 2019 15:09
Show Gist options
  • Save bryanmaina/ff1bd503d5cfdab1976cf4583a6bebfa to your computer and use it in GitHub Desktop.
Save bryanmaina/ff1bd503d5cfdab1976cf4583a6bebfa to your computer and use it in GitHub Desktop.
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