/*
* 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.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;
A connection to the database server.
NOTE: This class has been automatically generated from the original
non RX-ified interface using Vert.x codegen. /**
* A connection to the database server.
*
* <p/>
* NOTE: This class has been automatically generated from the {@link io.vertx.sqlclient.SqlConnection original} non RX-ified interface using Vert.x codegen.
*/
@RxGen(io.vertx.sqlclient.SqlConnection.class)
public class SqlConnection extends io.vertx.reactivex.sqlclient.SqlClient {
@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;
SqlConnection that = (SqlConnection) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
public static final TypeArg<SqlConnection> __TYPE_ARG = new TypeArg<>( obj -> new SqlConnection((io.vertx.sqlclient.SqlConnection) obj),
SqlConnection::getDelegate
);
private final io.vertx.sqlclient.SqlConnection delegate;
public SqlConnection(io.vertx.sqlclient.SqlConnection delegate) {
super(delegate);
this.delegate = delegate;
}
public SqlConnection(Object delegate) {
super((io.vertx.sqlclient.SqlConnection)delegate);
this.delegate = (io.vertx.sqlclient.SqlConnection)delegate;
}
public io.vertx.sqlclient.SqlConnection getDelegate() {
return delegate;
}
Create a prepared statement using the given sql
string.
Params: - sql – the sql
- handler – the handler notified with the prepared query asynchronously
Returns:
/**
* Create a prepared statement using the given <code>sql</code> string.
* @param sql the sql
* @param handler the handler notified with the prepared query asynchronously
* @return
*/
public io.vertx.reactivex.sqlclient.SqlConnection prepare(String sql, Handler<AsyncResult<io.vertx.reactivex.sqlclient.PreparedStatement>> handler) {
delegate.prepare(sql, new Handler<AsyncResult<io.vertx.sqlclient.PreparedStatement>>() {
public void handle(AsyncResult<io.vertx.sqlclient.PreparedStatement> ar) {
if (ar.succeeded()) {
handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.reactivex.sqlclient.PreparedStatement.newInstance((io.vertx.sqlclient.PreparedStatement)ar.result())));
} else {
handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
return this;
}
Create a prepared statement using the given sql
string.
Params: - sql – the sql
Returns:
/**
* Create a prepared statement using the given <code>sql</code> string.
* @param sql the sql
* @return
*/
public io.vertx.reactivex.sqlclient.SqlConnection prepare(String sql) {
return
prepare(sql, ar -> { });
}
Create a prepared statement using the given sql
string.
Params: - sql – the sql
Returns:
/**
* Create a prepared statement using the given <code>sql</code> string.
* @param sql the sql
* @return
*/
public io.reactivex.Single<io.vertx.reactivex.sqlclient.PreparedStatement> rxPrepare(String sql) {
return AsyncResultSingle.toSingle($handler -> {
prepare(sql, $handler);
});
}
Set an handler called with connection errors.
Params: - handler – the handler
Returns: a reference to this, so the API can be used fluently
/**
* Set an handler called with connection errors.
* @param handler the handler
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.sqlclient.SqlConnection exceptionHandler(Handler<java.lang.Throwable> handler) {
delegate.exceptionHandler(handler);
return this;
}
Set an handler called when the connection is closed.
Params: - handler – the handler
Returns: a reference to this, so the API can be used fluently
/**
* Set an handler called when the connection is closed.
* @param handler the handler
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.sqlclient.SqlConnection closeHandler(Handler<Void> handler) {
delegate.closeHandler(handler);
return this;
}
Begin a transaction and returns a Transaction
for controlling and tracking this transaction.
When the connection is explicitely closed, any inflight transaction is rollbacked.
Params: - handler –
/**
* Begin a transaction and returns a {@link io.vertx.reactivex.sqlclient.Transaction} for controlling and tracking
* this transaction.
* <p/>
* When the connection is explicitely closed, any inflight transaction is rollbacked.
* @param handler
*/
public void begin(Handler<AsyncResult<io.vertx.reactivex.sqlclient.Transaction>> handler) {
delegate.begin(new Handler<AsyncResult<io.vertx.sqlclient.Transaction>>() {
public void handle(AsyncResult<io.vertx.sqlclient.Transaction> ar) {
if (ar.succeeded()) {
handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.reactivex.sqlclient.Transaction.newInstance((io.vertx.sqlclient.Transaction)ar.result())));
} else {
handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
}
Begin a transaction and returns a Transaction
for controlling and tracking this transaction.
When the connection is explicitely closed, any inflight transaction is rollbacked.
/**
* Begin a transaction and returns a {@link io.vertx.reactivex.sqlclient.Transaction} for controlling and tracking
* this transaction.
* <p/>
* When the connection is explicitely closed, any inflight transaction is rollbacked.
*/
public void begin() {
begin(ar -> { });
}
Begin a transaction and returns a Transaction
for controlling and tracking this transaction.
When the connection is explicitely closed, any inflight transaction is rollbacked.
Returns:
/**
* Begin a transaction and returns a {@link io.vertx.reactivex.sqlclient.Transaction} for controlling and tracking
* this transaction.
* <p/>
* When the connection is explicitely closed, any inflight transaction is rollbacked.
* @return
*/
public io.reactivex.Single<io.vertx.reactivex.sqlclient.Transaction> rxBegin() {
return AsyncResultSingle.toSingle($handler -> {
begin($handler);
});
}
Returns: whether the connection uses SSL
/**
* @return whether the connection uses SSL
*/
public boolean isSSL() {
boolean ret = delegate.isSSL();
return ret;
}
Close the current connection after all the pending commands have been processed.
Params: - handler – the completion handler
/**
* Close the current connection after all the pending commands have been processed.
* @param handler the completion handler
*/
public void close(Handler<AsyncResult<Void>> handler) {
delegate.close(handler);
}
Close the current connection after all the pending commands have been processed.
/**
* Close the current connection after all the pending commands have been processed.
*/
public void close() {
close(ar -> { });
}
Close the current connection after all the pending commands have been processed.
Returns:
/**
* Close the current connection after all the pending commands have been processed.
* @return
*/
public io.reactivex.Completable rxClose() {
return AsyncResultCompletable.toCompletable($handler -> {
close($handler);
});
}
Returns: The static metadata about the backend database server for this connection
/**
* @return The static metadata about the backend database server for this connection
*/
public io.vertx.reactivex.sqlclient.spi.DatabaseMetadata databaseMetadata() {
io.vertx.reactivex.sqlclient.spi.DatabaseMetadata ret = io.vertx.reactivex.sqlclient.spi.DatabaseMetadata.newInstance((io.vertx.sqlclient.spi.DatabaseMetadata)delegate.databaseMetadata());
return ret;
}
public static SqlConnection newInstance(io.vertx.sqlclient.SqlConnection arg) {
return arg != null ? new SqlConnection(arg) : null;
}
}