@Test public void testC5FutureCallback_Success() throws Exception { Integer futureValue = 12; context.checking(new Expectations() {{ oneOf(mockFuture).get(); will(returnValue(futureValue)); oneOf(success).accept(futureValue); }}); C5Futures.addCallback(mockFuture, success, failure, mockFiber); }
public static <V> void addCallback(@NotNull ListenableFuture<V> future, @NotNull Consumer<? super V> success, @NotNull Consumer<Throwable> failure, @NotNull Fiber fiber) { Runnable callbackListener = () -> { final V value; try { value = getUninterruptibly(future); } catch (ExecutionException | RuntimeException | Error e) { failure.accept(e); return; } success.accept(value); }; future.addListener(callbackListener, fiber); }
C5Futures { public static <V> void addCallback(@NotNull ListenableFuture<V> future, @NotNull Consumer<? super V> success, @NotNull Consumer<Throwable> failure, @NotNull Fiber fiber) { Runnable callbackListener = () -> { final V value; try { value = getUninterruptibly(future); } catch (ExecutionException | RuntimeException | Error e) { failure.accept(e); return; } success.accept(value); }; future.addListener(callbackListener, fiber); } }
C5Futures { public static <V> void addCallback(@NotNull ListenableFuture<V> future, @NotNull Consumer<? super V> success, @NotNull Consumer<Throwable> failure, @NotNull Fiber fiber) { Runnable callbackListener = () -> { final V value; try { value = getUninterruptibly(future); } catch (ExecutionException | RuntimeException | Error e) { failure.accept(e); return; } success.accept(value); }; future.addListener(callbackListener, fiber); }  }
C5Futures { public static <V> void addCallback(@NotNull ListenableFuture<V> future, @NotNull Consumer<? super V> success, @NotNull Consumer<Throwable> failure, @NotNull Fiber fiber) { Runnable callbackListener = () -> { final V value; try { value = getUninterruptibly(future); } catch (ExecutionException | RuntimeException | Error e) { failure.accept(e); return; } success.accept(value); }; future.addListener(callbackListener, fiber); }  static void addCallback(@NotNull ListenableFuture<V> future,
                                     @NotNull Consumer<? super V> success,
                                     @NotNull Consumer<Throwable> failure,
                                     @NotNull Fiber fiber); static V getUninterruptibly(@NotNull Future<V> future); }
C5Futures { public static <V> void addCallback(@NotNull ListenableFuture<V> future, @NotNull Consumer<? super V> success, @NotNull Consumer<Throwable> failure, @NotNull Fiber fiber) { Runnable callbackListener = () -> { final V value; try { value = getUninterruptibly(future); } catch (ExecutionException | RuntimeException | Error e) { failure.accept(e); return; } success.accept(value); }; future.addListener(callbackListener, fiber); }  static void addCallback(@NotNull ListenableFuture<V> future,
                                     @NotNull Consumer<? super V> success,
                                     @NotNull Consumer<Throwable> failure,
                                     @NotNull Fiber fiber); static V getUninterruptibly(@NotNull Future<V> future);  }