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

io.vertx.rxjava.sqlclient.ClientBuilder 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 io.vertx.rxjava.sqlclient;

import rx.Observable;
import rx.Single;
import io.vertx.rx.java.RxHelper;
import io.vertx.rx.java.WriteStreamSubscriber;
import io.vertx.rx.java.SingleOnSubscribeAdapter;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.function.Supplier;
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;

/**
 * Builder for {@link io.vertx.rxjava.sqlclient.SqlClient} instances.
 *
 * 

* NOTE: This class has been automatically generated from the {@link io.vertx.sqlclient.ClientBuilder original} non RX-ified interface using Vert.x codegen. */ @RxGen(io.vertx.sqlclient.ClientBuilder.class) public class ClientBuilder { @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; ClientBuilder that = (ClientBuilder) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final TypeArg __TYPE_ARG = new TypeArg<>( obj -> new ClientBuilder((io.vertx.sqlclient.ClientBuilder) obj), ClientBuilder::getDelegate ); private final io.vertx.sqlclient.ClientBuilder delegate; public final TypeArg __typeArg_0; public ClientBuilder(io.vertx.sqlclient.ClientBuilder delegate) { this.delegate = delegate; this.__typeArg_0 = TypeArg.unknown(); } public ClientBuilder(Object delegate, TypeArg typeArg_0) { this.delegate = (io.vertx.sqlclient.ClientBuilder)delegate; this.__typeArg_0 = typeArg_0; } public io.vertx.sqlclient.ClientBuilder getDelegate() { return delegate; } /** * Configure the client with the given pool options * @param options the pool options * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.sqlclient.ClientBuilder with(io.vertx.sqlclient.PoolOptions options) { delegate.with(options); return this; } /** * Configure the client pool with the given transport options. * Note: the SSL options part is ignored, since {@link io.vertx.sqlclient.SqlConnectOptions} configures the transport SSL. * @param options the transport options * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.sqlclient.ClientBuilder with(io.vertx.core.net.NetClientOptions options) { delegate.with(options); return this; } /** * Configure the database the client should connect to. The target database is specified as * a {@link io.vertx.sqlclient.SqlConnectOptions} coordinates. * @param database the database coordinates * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.sqlclient.ClientBuilder connectingTo(io.vertx.sqlclient.SqlConnectOptions database) { delegate.connectingTo(database); return this; } /** * Configure the database the client should connect to. The target database is specified as * a {@link io.vertx.sqlclient.SqlConnectOptions} coordinates. * @param database the database URI * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.sqlclient.ClientBuilder connectingTo(java.lang.String database) { delegate.connectingTo(database); return this; } /** * Configure the database the client should connect to. When the client needs to connect to the database, * it gets fresh database configuration from the database supplier. * @param supplier the supplier of database coordinates * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.sqlclient.ClientBuilder connectingTo(java.util.function.Supplier> supplier) { delegate.connectingTo(new Supplier>() { public io.vertx.core.Future get() { io.vertx.core.Future ret = supplier.get(); return ret.map(val -> val); } }); return this; } /** * Configure the database the client should connect to. When the client needs to connect to the database, * it gets a database configuration from the list of databases using a round-robin policy. * @param databases the list of database coordinates * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.sqlclient.ClientBuilder connectingTo(java.util.List databases) { delegate.connectingTo(databases); return this; } /** * Sets the vertx instance to use. * @param vertx the vertx instance * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.sqlclient.ClientBuilder using(io.vertx.rxjava.core.Vertx vertx) { delegate.using(vertx.getDelegate()); return this; } /** * Set a handler called when the pool has established a connection to the database. * *

This handler allows interactions with the database before the connection is added to the pool. * *

When the handler has finished, it must call {@link io.vertx.rxjava.sqlclient.SqlClient#close} to release the connection * to the pool. * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.sqlclient.ClientBuilder withConnectHandler(io.vertx.core.Handler handler) { delegate.withConnectHandler(new io.vertx.lang.rx.DelegatingHandler<>(handler, event -> io.vertx.rxjava.sqlclient.SqlConnection.newInstance((io.vertx.sqlclient.SqlConnection)event))); return this; } /** * Build and return the client. * @return the client */ public C build() { C ret = (C)__typeArg_0.wrap(delegate.build()); return ret; } public static ClientBuilder newInstance(io.vertx.sqlclient.ClientBuilder arg) { return arg != null ? new ClientBuilder(arg) : null; } public static ClientBuilder newInstance(io.vertx.sqlclient.ClientBuilder arg, TypeArg __typeArg_C) { return arg != null ? new ClientBuilder(arg, __typeArg_C) : null; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy