-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Make ListenableFuture compliant with Java 8 lambda #571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/cc @poutsma in case you have any comments. |
* @param successCallback the success callback to register | ||
* @since 4.1 | ||
*/ | ||
ListenableFuture<T> onSuccess(ListenableFutureSuccessCallback<T> successCallback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be parameterized over ? super T
, just like the addCallback
signature?
I left some line comments. If you'd like, @sdeleuze, we can do a Skype call this week to talk things through. |
@poutsma Thanks! I will contact you shortly to plan a Skype call. |
@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). |
* @param failureCallback the failure callback to register | ||
* @since 4.1 | ||
*/ | ||
void addCallback(final ListenableFutureSuccessCallback<? super T> successCallback, final ListenableFutureFailureCallback failureCallback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need the final
on the parameters here.
I left two comments, but the rest looks OK to me. I would talk to @jhoeller about the |
@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 |
@philwebb I have taken your coding style feedbacks in account. |
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! |
Make it possible to use a ListenableFuture with Java 8 lambda expressions, using a syntax like listenableFuture.addCallback(() -> ..., () -> ...); Issue: SPR-11820
I have updated the names to SuccessCallback and FailureCallback, and rebased the commit against latest master. |
Make ListenableFuture compliant with Java 8 lambda
Make it possible to use a ListenableFuture with Java 8
lambda expressions, using a syntax like
listenableFuture.onSuccess(() -> ...).onFailure(() -> ...);
Issue: SPR-11820