Skip to content
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

Add lambda friendly addCallback. #16

Merged
merged 4 commits into from
Oct 30, 2015
Merged

Add lambda friendly addCallback. #16

merged 4 commits into from
Oct 30, 2015

Conversation

alanw
Copy link
Contributor

@alanw alanw commented Oct 29, 2015

No description provided.

@rschildmeijer
Copy link
Contributor

Looks good.

My only concern is that we allow null for the consumers (for one or for both).

You can attach callbacks that are run depending on the results of a future:
```java
final ListenableFuture<A> future = getFuture();
FuturesExtra.addCallback(future, a -> System.out.println(a), e -> e.printStackTrace());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this example could also use method references: System.out::println and Throwable::printStackTrace

* only be run if the future fails.
* @param future a ListenableFuture to attach the callbacks to.
* @param success a consumer, to be called with the result of the successful future.
* @param failure a consumer, to be called with the result of the failed future.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

document the nullability-rules of the parameters (both may not be null)

* @param future a ListenableFuture to attach the callbacks to.
* @param success a consumer, to be called with the result of the successful future.
* @param failure a consumer, to be called with the result of the failed future.
* @throws NullPointerException if the {@param success} and {@param failure} are null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is slightly unclear (not obvious that both have to be null for it to throw) but i dont want to reject the change based on that.

spkrka added a commit that referenced this pull request Oct 30, 2015
Add lambda friendly addCallback.
@spkrka spkrka merged commit a90098d into spotify:master Oct 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants