Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static <T1, T2, T3> ForSupplier3Option<T1, T2, T3> For(Supplier<Option<T1>> ts1,
- Supplier<Option<T2>> ts2,
- Supplier<Option<T3>> ts3) {
- return new ForSupplier3Option<>(ts1, ts2, ts3);
- }
- public static class ForSupplier3Option<T1, T2, T3> {
- private final Supplier<Option<T1>> ts1;
- private final Supplier<Option<T2>> ts2;
- private final Supplier<Option<T3>> ts3;
- private ForSupplier3Option(Supplier<Option<T1>> ts1, Supplier<Option<T2>> ts2, Supplier<Option<T3>> ts3) {
- this.ts1 = ts1;
- this.ts2 = ts2;
- this.ts3 = ts3;
- }
- public <R> Option<R> yield(Function3<? super T1, ? super T2, ? super T3, ? extends R> f) {
- Objects.requireNonNull(f, "f is null");
- return
- ts1.get().flatMap(t1 ->
- ts2.get().flatMap(t2 ->
- ts3.get().map(t3 -> f.apply(t1, t2, t3))));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement