All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.julienviet.reactivex.pgclient.PgPreparedQuery Maven / Gradle / Ivy

/*
 * Copyright 2014 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package com.julienviet.reactivex.pgclient;

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;

/**
 * A prepared query.
 *
 * 

* NOTE: This class has been automatically generated from the {@link com.julienviet.pgclient.PgPreparedQuery original} non RX-ified interface using Vert.x codegen. */ @io.vertx.lang.reactivex.RxGen(com.julienviet.pgclient.PgPreparedQuery.class) public class PgPreparedQuery { @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; PgPreparedQuery that = (PgPreparedQuery) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final io.vertx.lang.reactivex.TypeArg __TYPE_ARG = new io.vertx.lang.reactivex.TypeArg<>( obj -> new PgPreparedQuery((com.julienviet.pgclient.PgPreparedQuery) obj), PgPreparedQuery::getDelegate ); private final com.julienviet.pgclient.PgPreparedQuery delegate; public PgPreparedQuery(com.julienviet.pgclient.PgPreparedQuery delegate) { this.delegate = delegate; } public com.julienviet.pgclient.PgPreparedQuery getDelegate() { return delegate; } /** * @param handler * @return create a query with no arguments */ public PgPreparedQuery execute(Handler>> handler) { PgPreparedQuery ret = PgPreparedQuery.newInstance(delegate.execute(new Handler>>() { public void handle(AsyncResult> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(PgResult.newInstance(ar.result(), com.julienviet.reactivex.pgclient.Row.__TYPE_ARG))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } })); return ret; } /** * Create a cursor with the provided arguments. * @param args the list of arguments * @param handler * @return the query */ public PgPreparedQuery execute(Tuple args, Handler>> handler) { PgPreparedQuery ret = PgPreparedQuery.newInstance(delegate.execute(args.getDelegate(), new Handler>>() { public void handle(AsyncResult> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(PgResult.newInstance(ar.result(), com.julienviet.reactivex.pgclient.Row.__TYPE_ARG))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } })); return ret; } /** * @return create a query cursor with a fetch size and empty arguments */ public PgCursor cursor() { PgCursor ret = PgCursor.newInstance(delegate.cursor()); return ret; } /** * Create a cursor with the provided arguments. * @param args the list of arguments * @return the query */ public PgCursor cursor(Tuple args) { PgCursor ret = PgCursor.newInstance(delegate.cursor(args.getDelegate())); return ret; } /** * Execute the prepared query with a cursor and createStream the result. The createStream opens a cursor * with a fetch size to fetch the results. *

* Note: this requires to be in a transaction, since cursors require it. * @param fetch the cursor fetch size * @param args the prepared query arguments * @return the createStream */ public PgStream createStream(int fetch, Tuple args) { PgStream ret = PgStream.newInstance(delegate.createStream(fetch, args.getDelegate()), com.julienviet.reactivex.pgclient.Row.__TYPE_ARG); return ret; } /** * Execute a batch. * @param argsList the list of tuple for the batch * @param handler * @return the createBatch */ public PgPreparedQuery batch(List argsList, Handler>> handler) { delegate.batch(argsList.stream().map(elt -> elt.getDelegate()).collect(java.util.stream.Collectors.toList()), new Handler>>() { public void handle(AsyncResult> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(PgResult.newInstance(ar.result(), com.julienviet.reactivex.pgclient.Row.__TYPE_ARG))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; } /** * Execute a batch. * @param argsList the list of tuple for the batch * @return */ public Single> rxBatch(List argsList) { return new io.vertx.reactivex.core.impl.AsyncResultSingle>(handler -> { batch(argsList, handler); }); } /** * Close the prepared query and release its resources. */ public void close() { delegate.close(); } /** * Like {@link com.julienviet.reactivex.pgclient.PgPreparedQuery#close} but notifies the completionHandler when it's closed. * @param completionHandler */ public void close(Handler> completionHandler) { delegate.close(completionHandler); } /** * Like {@link com.julienviet.reactivex.pgclient.PgPreparedQuery#close} but notifies the completionHandler when it's closed. * @return */ public Completable rxClose() { return new io.vertx.reactivex.core.impl.AsyncResultCompletable(handler -> { close(handler); }); } public static PgPreparedQuery newInstance(com.julienviet.pgclient.PgPreparedQuery arg) { return arg != null ? new PgPreparedQuery(arg) : null; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy