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

io.sphere.internal.ListenableFutureAdapter Maven / Gradle / Ivy

There is a newer version: 0.72.1
Show newest version
package io.sphere.internal;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import com.google.common.util.concurrent.ListenableFuture;

/** Adapter from AsyncHttpClient ListenableFuture to Guava ListenableFuture. */
public final class ListenableFutureAdapter implements ListenableFuture {
    private final com.ning.http.client.ListenableFuture ahcFuture;

    public ListenableFutureAdapter(com.ning.http.client.ListenableFuture ahcFuture) {
        this.ahcFuture = ahcFuture;
    }

    @Override public void addListener(Runnable r, Executor exec) {
        this.ahcFuture.addListener(r, exec);
    }

    @Override public V get() throws InterruptedException, ExecutionException { return this.ahcFuture.get(); }
    @Override public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
        return this.ahcFuture.get(timeout, unit);
    }
    @Override public boolean isDone() { return this.ahcFuture.isDone(); }
    @Override public boolean isCancelled() { return this.ahcFuture.isCancelled(); }
    @Override public boolean cancel(boolean mayInterruptIfRunning) { return this.ahcFuture.cancel(mayInterruptIfRunning); }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy