futureB) { 4 return Futures.transform(futureA, new AsyncFunction<Integer, Integer>() { 5 @Override 6 public ListenableFuture<Integer> apply(final Integer resultA) throws Exception { 7 return Futures.transform(futureB, new AsyncFunction<Integer, Integer>() { 8 @Override 9 public ListenableFuture<Integer> apply(Integer resultB) throws Exception { 10 return Futures.immediateCheckedFuture(resultA + resultB); 11 } 12 }); 13 } 14 }); 15} Callback Hell in Guava’s Future public interface AsyncFunction<I, O> { ListenableFuture<O> apply(I input) throws Exception; } static <I,O>ListenableFuture<O> transform( ListenableFuture<I> input, AsyncFunction<? super I,? extends O> function) one line of valuable code with 14 lines of boilerplate Friday, August 2, 13