Make it possible to use a ListenableFuture with Java 8 lambda expressions, using a syntax like listenableFuture.onSuccess(() -> ...).onFailure(() -> ...);

Issue: SPR-11820

Comment From: rstoyanchev

/cc @poutsma in case you have any comments.

Comment From: poutsma

I left some line comments. If you'd like, @sdeleuze, we can do a Skype call this week to talk things through.

Comment From: sdeleuze

@poutsma Thanks! I will contact you shortly to plan a Skype call.

Comment From: sdeleuze

@poutsma Could you review this new commit? I tried to take in account all your feedbacks, including your API proposal (addCallback method with successCallback and failureCallback parameters instead of onSuccess and onFailure methods)

I have rebased it against latest master, so there is new changes (mostly the AsyncResult that now extends ListenableFuture instead of Future, I wrote a comment asking some feedback in the commit).

Comment From: poutsma

I left two comments, but the rest looks OK to me. I would talk to @jhoeller about the AsyncResult changes.

Comment From: sdeleuze

@poutsma Thanks for your review, very interesting for me, and we now have a better API :-)

@jhoeller Could you have a look to this PR, especially my AsyncResult addCallback changes (not directly related to this issue, but It seemed to me that it was a good idea to call onFailure callback when an exception is thrown). If everything is ok, could you merge it to master? Thanks!

Comment From: sdeleuze

@philwebb I have taken your coding style feedbacks in account.

Comment From: jhoeller

I wonder whether we should shorten the ListenableFuture*Callback names to just SuccessCallback and FailureCallback, with only ListenableFutureCallback keeping its distinct name. Those interfaces are qualified by their package name, after all, and four-word callback names seem a bit longish, in particular one after each other in the same method signature...

Other than that, this approach looks fine to me!

Comment From: sdeleuze

I have updated the names to SuccessCallback and FailureCallback, and rebased the commit against latest master.