Ejemplo n.º 1
0
 @Override
 public <U> Promise<U> handle(BiFunction<? super T, Throwable, ? extends U> fn) {
   final java.util.function.BiFunction<? super T, Throwable, ? extends U> bifn =
       (t, u) -> {
         try {
           return fn.apply(t, u);
         } catch (Exception e) {
           throw new PromiseRuntimeException(e);
         }
       };
   return w(f.handleAsync(bifn, promiseExecuter));
 }
Ejemplo n.º 2
0
 @Override
 public <U, V> Promise<V> thenCombine(
     Promise<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) {
   final java.util.function.BiFunction<? super T, ? super U, ? extends V> bifn =
       (t, u) -> {
         try {
           return fn.apply(t, u);
         } catch (Exception e) {
           throw new PromiseRuntimeException(e);
         }
       };
   final CompletionStage<? extends U> v = v(other);
   return w(f.thenCombineAsync(v, bifn, promiseExecuter));
 }