io.reactiverse.mutiny.pgclient.PgCursor Maven / Gradle / Ivy
package io.reactiverse.mutiny.pgclient;
import java.util.Map;
import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.Uni;
import java.util.function.Consumer;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Publisher;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
/**
* A cursor that reads progressively the rows from Postgres, it is usefull for reading very large result.
*
*
* NOTE: This class has been automatically generated from the {@link io.reactiverse.pgclient.PgCursor original} non Mutiny-ified interface using Vert.x codegen.
*/
@io.smallrye.mutiny.vertx.MutinyGen(io.reactiverse.pgclient.PgCursor.class)
public class PgCursor {
public static final io.smallrye.mutiny.vertx.TypeArg __TYPE_ARG = new io.smallrye.mutiny.vertx.TypeArg<>( obj -> new PgCursor((io.reactiverse.pgclient.PgCursor) obj),
PgCursor::getDelegate
);
private final io.reactiverse.pgclient.PgCursor delegate;
public PgCursor(io.reactiverse.pgclient.PgCursor delegate) {
this.delegate = delegate;
}
/**
* Empty constructor used by CDI, do not use this constructor directly.
**/
PgCursor() { this.delegate = null;
}
public io.reactiverse.pgclient.PgCursor getDelegate() {
return delegate;
}
@Override
public String toString() {
return delegate.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PgCursor that = (PgCursor) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
/**
* Read rows from the cursor, the result is provided asynchronously to the handler
.
* @param count the amount of rows to read
* @param handler the handler for the result
*/
private void __read(int count, Handler> handler) {
delegate.read(count, new Handler>() {
public void handle(AsyncResult ar) {
if (ar.succeeded()) {
handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.mutiny.pgclient.PgRowSet.newInstance(ar.result())));
} else {
handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
}
/**
* Read rows from the cursor, the result is provided asynchronously to the handler
.
* @param count the amount of rows to read
* @return
*/
public Uni read(int count) {
return io.smallrye.mutiny.vertx.AsyncResultUni.toUni(handler -> {
__read(count, handler);
});
}
/**
* Read rows from the cursor, the result is provided asynchronously to the handler
.
* @param count the amount of rows to read
* @return
*/
public io.reactiverse.mutiny.pgclient.PgRowSet readAndAwait(int count) {
return (io.reactiverse.mutiny.pgclient.PgRowSet) read(count).await().indefinitely();
}
/**
* Returns true
when the cursor has results in progress and the should be called to retrieve
* them.
* @return whether the cursor has more results,
*/
public boolean hasMore() {
boolean ret = delegate.hasMore();
return ret;
}
/**
* Like {@link io.reactiverse.mutiny.pgclient.PgCursor#close} but with a completionHandler
called when the cursor has been released.
* @param completionHandler
*/
private void __close(Handler> completionHandler) {
delegate.close(completionHandler);
}
/**
* Like {@link io.reactiverse.mutiny.pgclient.PgCursor#close} but with a completionHandler
called when the cursor has been released.
* @return
*/
public Uni close() {
return io.smallrye.mutiny.vertx.AsyncResultUni.toUni(handler -> {
__close(handler);
});
}
/**
* Like {@link io.reactiverse.mutiny.pgclient.PgCursor#close} but with a completionHandler
called when the cursor has been released.
* @return
*/
public Void closeAndAwait() {
return (Void) close().await().indefinitely();
}
public static PgCursor newInstance(io.reactiverse.pgclient.PgCursor arg) {
return arg != null ? new PgCursor(arg) : null;
}
}