package io.reactiverse.rxjava.pgclient;
import java.util.Map;
import rx.Observable;
import rx.Single;
import java.util.List;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
@io.vertx.lang.rx.RxGen(io.reactiverse.pgclient.PgPool.class)
public class PgPool extends io.reactiverse.rxjava.pgclient.PgClient {
@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;
PgPool that = (PgPool) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
public static final io.vertx.lang.rx.TypeArg<PgPool> __TYPE_ARG = new io.vertx.lang.rx.TypeArg<>( obj -> new PgPool((io.reactiverse.pgclient.PgPool) obj),
PgPool::getDelegate
);
private final io.reactiverse.pgclient.PgPool delegate;
public PgPool(io.reactiverse.pgclient.PgPool delegate) {
super(delegate);
this.delegate = delegate;
}
public io.reactiverse.pgclient.PgPool getDelegate() {
return delegate;
}
public io.reactiverse.rxjava.pgclient.PgPool preparedQuery(String sql, Handler<AsyncResult<io.reactiverse.rxjava.pgclient.PgRowSet>> handler) {
delegate.preparedQuery(sql, new Handler<AsyncResult<io.reactiverse.pgclient.PgRowSet>>() {
public void handle(AsyncResult<io.reactiverse.pgclient.PgRowSet> ar) {
if (ar.succeeded()) {
handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.rxjava.pgclient.PgRowSet.newInstance(ar.result())));
} else {
handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
return this;
}
public Single<io.reactiverse.rxjava.pgclient.PgRowSet> rxPreparedQuery(String sql) {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
preparedQuery(sql, fut);
}));
}
public io.reactiverse.rxjava.pgclient.PgPool query(String sql, Handler<AsyncResult<io.reactiverse.rxjava.pgclient.PgRowSet>> handler) {
delegate.query(sql, new Handler<AsyncResult<io.reactiverse.pgclient.PgRowSet>>() {
public void handle(AsyncResult<io.reactiverse.pgclient.PgRowSet> ar) {
if (ar.succeeded()) {
handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.rxjava.pgclient.PgRowSet.newInstance(ar.result())));
} else {
handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
return this;
}
public Single<io.reactiverse.rxjava.pgclient.PgRowSet> rxQuery(String sql) {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
query(sql, fut);
}));
}
public io.reactiverse.rxjava.pgclient.PgPool preparedQuery(String sql, io.reactiverse.rxjava.pgclient.Tuple arguments, Handler<AsyncResult<io.reactiverse.rxjava.pgclient.PgRowSet>> handler) {
delegate.preparedQuery(sql, arguments.getDelegate(), new Handler<AsyncResult<io.reactiverse.pgclient.PgRowSet>>() {
public void handle(AsyncResult<io.reactiverse.pgclient.PgRowSet> ar) {
if (ar.succeeded()) {
handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.rxjava.pgclient.PgRowSet.newInstance(ar.result())));
} else {
handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
return this;
}
public Single<io.reactiverse.rxjava.pgclient.PgRowSet> rxPreparedQuery(String sql, io.reactiverse.rxjava.pgclient.Tuple arguments) {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
preparedQuery(sql, arguments, fut);
}));
}
public io.reactiverse.rxjava.pgclient.PgPool preparedBatch(String sql, List<io.reactiverse.rxjava.pgclient.Tuple> batch, Handler<AsyncResult<io.reactiverse.rxjava.pgclient.PgRowSet>> handler) {
delegate.preparedBatch(sql, batch.stream().map(elt -> elt.getDelegate()).collect(java.util.stream.Collectors.toList()), new Handler<AsyncResult<io.reactiverse.pgclient.PgRowSet>>() {
public void handle(AsyncResult<io.reactiverse.pgclient.PgRowSet> ar) {
if (ar.succeeded()) {
handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.rxjava.pgclient.PgRowSet.newInstance(ar.result())));
} else {
handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
return this;
}
public Single<io.reactiverse.rxjava.pgclient.PgRowSet> rxPreparedBatch(String sql, List<io.reactiverse.rxjava.pgclient.Tuple> batch) {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
preparedBatch(sql, batch, fut);
}));
}
public void getConnection(Handler<AsyncResult<io.reactiverse.rxjava.pgclient.PgConnection>> handler) {
delegate.getConnection(new Handler<AsyncResult<io.reactiverse.pgclient.PgConnection>>() {
public void handle(AsyncResult<io.reactiverse.pgclient.PgConnection> ar) {
if (ar.succeeded()) {
handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.rxjava.pgclient.PgConnection.newInstance(ar.result())));
} else {
handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
}
public Single<io.reactiverse.rxjava.pgclient.PgConnection> rxGetConnection() {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
getConnection(fut);
}));
}
public void begin(Handler<AsyncResult<io.reactiverse.rxjava.pgclient.PgTransaction>> handler) {
delegate.begin(new Handler<AsyncResult<io.reactiverse.pgclient.PgTransaction>>() {
public void handle(AsyncResult<io.reactiverse.pgclient.PgTransaction> ar) {
if (ar.succeeded()) {
handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.rxjava.pgclient.PgTransaction.newInstance(ar.result())));
} else {
handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
}
public Single<io.reactiverse.rxjava.pgclient.PgTransaction> rxBegin() {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
begin(fut);
}));
}
public void close() {
delegate.close();
}
public static PgPool newInstance(io.reactiverse.pgclient.PgPool arg) {
return arg != null ? new PgPool(arg) : null;
}
}