package io.vertx.reactivex.sqlclient;
import java.util.Map;
import io.reactivex.Observable;
import io.reactivex.Flowable;
import io.reactivex.Single;
import io.reactivex.Completable;
import io.reactivex.Maybe;
import java.util.List;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
@io.vertx.lang.rx.RxGen(io.vertx.sqlclient.PreparedQuery.class)
public class PreparedQuery {
@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;
PreparedQuery that = (PreparedQuery) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
public static final io.vertx.lang.rx.TypeArg<PreparedQuery> __TYPE_ARG = new io.vertx.lang.rx.TypeArg<>( obj -> new PreparedQuery((io.vertx.sqlclient.PreparedQuery) obj),
PreparedQuery::getDelegate
);
private final io.vertx.sqlclient.PreparedQuery delegate;
public PreparedQuery(io.vertx.sqlclient.PreparedQuery delegate) {
this.delegate = delegate;
}
public io.vertx.sqlclient.PreparedQuery getDelegate() {
return delegate;
}
public io.vertx.reactivex.sqlclient.PreparedQuery execute(Handler<AsyncResult<io.vertx.reactivex.sqlclient.RowSet>> handler) {
delegate.execute(new Handler<AsyncResult<io.vertx.sqlclient.RowSet>>() {
public void handle(AsyncResult<io.vertx.sqlclient.RowSet> ar) {
if (ar.succeeded()) {
handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.reactivex.sqlclient.RowSet.newInstance(ar.result())));
} else {
handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
return this;
}
public Single<io.vertx.reactivex.sqlclient.RowSet> rxExecute() {
return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> {
execute(handler);
});
}
public io.vertx.reactivex.sqlclient.PreparedQuery execute(io.vertx.reactivex.sqlclient.Tuple args, Handler<AsyncResult<io.vertx.reactivex.sqlclient.RowSet>> handler) {
delegate.execute(args.getDelegate(), new Handler<AsyncResult<io.vertx.sqlclient.RowSet>>() {
public void handle(AsyncResult<io.vertx.sqlclient.RowSet> ar) {
if (ar.succeeded()) {
handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.reactivex.sqlclient.RowSet.newInstance(ar.result())));
} else {
handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
return this;
}
public Single<io.vertx.reactivex.sqlclient.RowSet> rxExecute(io.vertx.reactivex.sqlclient.Tuple args) {
return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> {
execute(args, handler);
});
}
public io.vertx.reactivex.sqlclient.Cursor cursor() {
io.vertx.reactivex.sqlclient.Cursor ret = io.vertx.reactivex.sqlclient.Cursor.newInstance(delegate.cursor());
return ret;
}
public io.vertx.reactivex.sqlclient.Cursor cursor(io.vertx.reactivex.sqlclient.Tuple args) {
io.vertx.reactivex.sqlclient.Cursor ret = io.vertx.reactivex.sqlclient.Cursor.newInstance(delegate.cursor(args.getDelegate()));
return ret;
}
public io.vertx.reactivex.sqlclient.RowStream<io.vertx.reactivex.sqlclient.Row> createStream(int fetch, io.vertx.reactivex.sqlclient.Tuple args) {
io.vertx.reactivex.sqlclient.RowStream<io.vertx.reactivex.sqlclient.Row> ret = io.vertx.reactivex.sqlclient.RowStream.newInstance(delegate.createStream(fetch, args.getDelegate()), (io.vertx.lang.rx.TypeArg)io.vertx.reactivex.sqlclient.Row.__TYPE_ARG);
return ret;
}
public io.vertx.reactivex.sqlclient.PreparedQuery batch(List<io.vertx.reactivex.sqlclient.Tuple> argsList, Handler<AsyncResult<io.vertx.reactivex.sqlclient.RowSet>> handler) {
delegate.batch(argsList.stream().map(elt -> elt.getDelegate()).collect(java.util.stream.Collectors.toList()), new Handler<AsyncResult<io.vertx.sqlclient.RowSet>>() {
public void handle(AsyncResult<io.vertx.sqlclient.RowSet> ar) {
if (ar.succeeded()) {
handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.reactivex.sqlclient.RowSet.newInstance(ar.result())));
} else {
handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
return this;
}
public Single<io.vertx.reactivex.sqlclient.RowSet> rxBatch(List<io.vertx.reactivex.sqlclient.Tuple> argsList) {
return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> {
batch(argsList, handler);
});
}
public void close() {
delegate.close();
}
public void close(Handler<AsyncResult<Void>> completionHandler) {
delegate.close(completionHandler);
}
public Completable rxClose() {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
close(handler);
});
}
public static PreparedQuery newInstance(io.vertx.sqlclient.PreparedQuery arg) {
return arg != null ? new PreparedQuery(arg) : null;
}
}