package io.vertx.reactivex.sqlclient;
import io.vertx.reactivex.RxHelper;
import io.vertx.reactivex.ObservableHelper;
import io.vertx.reactivex.FlowableHelper;
import io.vertx.reactivex.impl.AsyncResultMaybe;
import io.vertx.reactivex.impl.AsyncResultSingle;
import io.vertx.reactivex.impl.AsyncResultCompletable;
import io.vertx.reactivex.WriteStreamObserver;
import io.vertx.reactivex.WriteStreamSubscriber;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.lang.rx.RxGen;
import io.vertx.lang.rx.TypeArg;
import io.vertx.lang.rx.MappingIterator;
@RxGen(io.vertx.sqlclient.PreparedQuery.class)
public class PreparedQuery<T> extends io.vertx.reactivex.sqlclient.Query<T> {
@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 TypeArg<PreparedQuery> __TYPE_ARG = new TypeArg<>( obj -> new PreparedQuery((io.vertx.sqlclient.PreparedQuery) obj),
PreparedQuery::getDelegate
);
private final io.vertx.sqlclient.PreparedQuery<T> delegate;
public final TypeArg<T> __typeArg_0;
public PreparedQuery(io.vertx.sqlclient.PreparedQuery delegate) {
super(delegate);
this.delegate = delegate;
this.__typeArg_0 = TypeArg.unknown(); }
public PreparedQuery(Object delegate, TypeArg<T> typeArg_0) {
super((io.vertx.sqlclient.PreparedQuery)delegate);
this.delegate = (io.vertx.sqlclient.PreparedQuery)delegate;
this.__typeArg_0 = typeArg_0;
}
public io.vertx.sqlclient.PreparedQuery getDelegate() {
return delegate;
}
public void execute(Handler<AsyncResult<T>> handler) {
delegate.execute(new Handler<AsyncResult<T>>() {
public void handle(AsyncResult<T> ar) {
if (ar.succeeded()) {
handler.handle(io.vertx.core.Future.succeededFuture((T)__typeArg_0.wrap(ar.result())));
} else {
handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
}
public void execute() {
execute(ar -> { });
}
public io.reactivex.Single<T> rxExecute() {
return AsyncResultSingle.toSingle($handler -> {
execute($handler);
});
}
public void execute(io.vertx.reactivex.sqlclient.Tuple tuple, Handler<AsyncResult<T>> handler) {
delegate.execute(tuple.getDelegate(), new Handler<AsyncResult<T>>() {
public void handle(AsyncResult<T> ar) {
if (ar.succeeded()) {
handler.handle(io.vertx.core.Future.succeededFuture((T)__typeArg_0.wrap(ar.result())));
} else {
handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
}
public void execute(io.vertx.reactivex.sqlclient.Tuple tuple) {
execute(tuple, ar -> { });
}
public io.reactivex.Single<T> rxExecute(io.vertx.reactivex.sqlclient.Tuple tuple) {
return AsyncResultSingle.toSingle($handler -> {
execute(tuple, $handler);
});
}
public void executeBatch(List<io.vertx.reactivex.sqlclient.Tuple> batch, Handler<AsyncResult<T>> handler) {
delegate.executeBatch(batch.stream().map(elt -> elt.getDelegate()).collect(Collectors.toList()), new Handler<AsyncResult<T>>() {
public void handle(AsyncResult<T> ar) {
if (ar.succeeded()) {
handler.handle(io.vertx.core.Future.succeededFuture((T)__typeArg_0.wrap(ar.result())));
} else {
handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
}
public void executeBatch(List<io.vertx.reactivex.sqlclient.Tuple> batch) {
executeBatch(batch, ar -> { });
}
public io.reactivex.Single<T> rxExecuteBatch(List<io.vertx.reactivex.sqlclient.Tuple> batch) {
return AsyncResultSingle.toSingle($handler -> {
executeBatch(batch, $handler);
});
}
public <U> io.vertx.reactivex.sqlclient.PreparedQuery<io.vertx.reactivex.sqlclient.RowSet<U>> mapping(Function<io.vertx.reactivex.sqlclient.Row, U> mapper) {
io.vertx.reactivex.sqlclient.PreparedQuery<io.vertx.reactivex.sqlclient.RowSet<U>> ret = io.vertx.reactivex.sqlclient.PreparedQuery.newInstance((io.vertx.sqlclient.PreparedQuery)delegate.mapping(new Function<io.vertx.sqlclient.Row,U>() {
public U apply(io.vertx.sqlclient.Row arg) {
U ret = mapper.apply(io.vertx.reactivex.sqlclient.Row.newInstance((io.vertx.sqlclient.Row)arg));
return ret;
}
}), new TypeArg<io.vertx.reactivex.sqlclient.RowSet<U>>(o0 -> io.vertx.reactivex.sqlclient.RowSet.newInstance((io.vertx.sqlclient.RowSet)o0, TypeArg.unknown()), o0 -> o0.getDelegate()));
return ret;
}
public static <T> PreparedQuery<T> newInstance(io.vertx.sqlclient.PreparedQuery arg) {
return arg != null ? new PreparedQuery<T>(arg) : null;
}
public static <T> PreparedQuery<T> newInstance(io.vertx.sqlclient.PreparedQuery arg, TypeArg<T> __typeArg_T) {
return arg != null ? new PreparedQuery<T>(arg, __typeArg_T) : null;
}
}