javastrava.api.async.StravaAPICallback Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javastrava-api Show documentation
Show all versions of javastrava-api Show documentation
Java implementation of the Strava API
The newest version!
package javastrava.api.async;
import retrofit.Callback;
import retrofit.RetrofitError;
import retrofit.client.Response;
/**
* @author Dan Shannon
* @param
* The type being returned to the callback
*
*/
public class StravaAPICallback implements Callback {
/**
* A Future which will be completed when the call to the API is complete
*/
private final StravaAPIFuture future;
/**
* @param completableFuture
* A Future which will be completed when the call to the API is complete
*/
public StravaAPICallback(final StravaAPIFuture completableFuture) {
this.future = completableFuture;
}
/**
* @see retrofit.Callback#failure(retrofit.RetrofitError)
*/
@Override
public void failure(final RetrofitError error) {
this.future.completeExceptionally(error.getCause());
}
/**
* @see retrofit.Callback#success(java.lang.Object, retrofit.client.Response)
*/
@Override
public void success(final T t, final Response response) {
this.future.complete(t);
}
}