io.github.openunirest.http.async.CallbackFuture Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unirest-java Show documentation
Show all versions of unirest-java Show documentation
Simplified, lightweight HTTP client library
package io.github.openunirest.http.async;
import io.github.openunirest.http.HttpResponse;
import io.github.openunirest.http.exceptions.UnirestException;
import java.util.concurrent.CompletableFuture;
public class CallbackFuture {
public static CompletableFuture> wrap(Callback source){
return new CompletableFuture>(){
@Override
public boolean complete(HttpResponse value) {
source.completed(value);
return super.complete(value);
}
@Override
public boolean completeExceptionally(Throwable ex) {
source.failed(new UnirestException(ex));
return super.completeExceptionally(ex);
}
@Override
public boolean cancel(boolean mayInterruptIfRunning) {
source.cancelled();
return super.cancel(mayInterruptIfRunning);
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy