All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javastrava.api.v3.rest.async.StravaAPICallback Maven / Gradle / Ivy

There is a newer version: 2.0.0-alpha
Show newest version
/**
 *
 */
package javastrava.api.v3.rest.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) {
		// final RuntimeException exception = (RuntimeException) errorHandler.handleError(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);

	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy