/*
 * 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.cassandra;

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;

Eclipse Vert.x Cassandra client.

NOTE: This class has been automatically generated from the original non RX-ified interface using Vert.x codegen.
/** * Eclipse Vert.x Cassandra client. * * <p/> * NOTE: This class has been automatically generated from the {@link io.vertx.cassandra.CassandraClient original} non RX-ified interface using Vert.x codegen. */
@RxGen(io.vertx.cassandra.CassandraClient.class) public class CassandraClient { @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; CassandraClient that = (CassandraClient) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final TypeArg<CassandraClient> __TYPE_ARG = new TypeArg<>( obj -> new CassandraClient((io.vertx.cassandra.CassandraClient) obj), CassandraClient::getDelegate ); private final io.vertx.cassandra.CassandraClient delegate; public CassandraClient(io.vertx.cassandra.CassandraClient delegate) { this.delegate = delegate; } public CassandraClient(Object delegate) { this.delegate = (io.vertx.cassandra.CassandraClient)delegate; } public io.vertx.cassandra.CassandraClient getDelegate() { return delegate; }
Like create with default options.
Params:
  • vertx –
Returns:
/** * Like {@link io.vertx.reactivex.cassandra.CassandraClient#create} with default options. * @param vertx * @return */
public static io.vertx.reactivex.cassandra.CassandraClient create(io.vertx.reactivex.core.Vertx vertx) { io.vertx.reactivex.cassandra.CassandraClient ret = io.vertx.reactivex.cassandra.CassandraClient.newInstance((io.vertx.cassandra.CassandraClient)io.vertx.cassandra.CassandraClient.create(vertx.getDelegate())); return ret; }
Create a Cassandra client which maintains its own driver session.

It is not recommended to create several non shared clients in an application.

Params:
  • vertx – the Vert.x instance
  • options – the options
Returns:the client
/** * Create a Cassandra client which maintains its own driver session. * <p> * It is not recommended to create several non shared clients in an application. * @param vertx the Vert.x instance * @param options the options * @return the client */
public static io.vertx.reactivex.cassandra.CassandraClient create(io.vertx.reactivex.core.Vertx vertx, io.vertx.cassandra.CassandraClientOptions options) { io.vertx.reactivex.cassandra.CassandraClient ret = io.vertx.reactivex.cassandra.CassandraClient.newInstance((io.vertx.cassandra.CassandraClient)io.vertx.cassandra.CassandraClient.create(vertx.getDelegate(), options)); return ret; }
Like createShared with default options and client name.
Params:
  • vertx –
Returns:
/** * Like {@link io.vertx.reactivex.cassandra.CassandraClient#createShared} with default options and client name. * @param vertx * @return */
public static io.vertx.reactivex.cassandra.CassandraClient createShared(io.vertx.reactivex.core.Vertx vertx) { io.vertx.reactivex.cassandra.CassandraClient ret = io.vertx.reactivex.cassandra.CassandraClient.newInstance((io.vertx.cassandra.CassandraClient)io.vertx.cassandra.CassandraClient.createShared(vertx.getDelegate())); return ret; }
Like createShared with default options.
Params:
  • vertx –
  • clientName –
Returns:
/** * Like {@link io.vertx.reactivex.cassandra.CassandraClient#createShared} with default options. * @param vertx * @param clientName * @return */
public static io.vertx.reactivex.cassandra.CassandraClient createShared(io.vertx.reactivex.core.Vertx vertx, String clientName) { io.vertx.reactivex.cassandra.CassandraClient ret = io.vertx.reactivex.cassandra.CassandraClient.newInstance((io.vertx.cassandra.CassandraClient)io.vertx.cassandra.CassandraClient.createShared(vertx.getDelegate(), clientName)); return ret; }
Like createShared with default client name.
Params:
  • vertx –
  • options –
Returns:
/** * Like {@link io.vertx.reactivex.cassandra.CassandraClient#createShared} with default client name. * @param vertx * @param options * @return */
public static io.vertx.reactivex.cassandra.CassandraClient createShared(io.vertx.reactivex.core.Vertx vertx, io.vertx.cassandra.CassandraClientOptions options) { io.vertx.reactivex.cassandra.CassandraClient ret = io.vertx.reactivex.cassandra.CassandraClient.newInstance((io.vertx.cassandra.CassandraClient)io.vertx.cassandra.CassandraClient.createShared(vertx.getDelegate(), options)); return ret; }
Create a Cassandra client that shares its driver session with any other client having the same name.
Params:
  • vertx – the Vert.x instance
  • clientName – the shared client name
  • options – the options
Returns:the client
/** * Create a Cassandra client that shares its driver session with any other client having the same name. * @param vertx the Vert.x instance * @param clientName the shared client name * @param options the options * @return the client */
public static io.vertx.reactivex.cassandra.CassandraClient createShared(io.vertx.reactivex.core.Vertx vertx, String clientName, io.vertx.cassandra.CassandraClientOptions options) { io.vertx.reactivex.cassandra.CassandraClient ret = io.vertx.reactivex.cassandra.CassandraClient.newInstance((io.vertx.cassandra.CassandraClient)io.vertx.cassandra.CassandraClient.createShared(vertx.getDelegate(), clientName, options)); return ret; }
Returns:whether this Cassandra client instance is connected
/** * @return whether this Cassandra client instance is connected */
public boolean isConnected() { boolean ret = delegate.isConnected(); return ret; }
Execute the query and provide a handler for consuming results.
Params:
  • query – the query to execute
  • resultHandler – handler called when result of execution is present, but can be not fully fetched
Returns:current Cassandra client instance
/** * Execute the query and provide a handler for consuming results. * @param query the query to execute * @param resultHandler handler called when result of execution is present, but can be not fully fetched * @return current Cassandra client instance */
public io.vertx.reactivex.cassandra.CassandraClient execute(String query, Handler<AsyncResult<io.vertx.reactivex.cassandra.ResultSet>> resultHandler) { delegate.execute(query, new Handler<AsyncResult<io.vertx.cassandra.ResultSet>>() { public void handle(AsyncResult<io.vertx.cassandra.ResultSet> ar) { if (ar.succeeded()) { resultHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.reactivex.cassandra.ResultSet.newInstance((io.vertx.cassandra.ResultSet)ar.result()))); } else { resultHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
Execute the query and provide a handler for consuming results.
Params:
  • query – the query to execute
Returns:current Cassandra client instance
/** * Execute the query and provide a handler for consuming results. * @param query the query to execute * @return current Cassandra client instance */
public io.vertx.reactivex.cassandra.CassandraClient execute(String query) { return execute(query, ar -> { }); }
Execute the query and provide a handler for consuming results.
Params:
  • query – the query to execute
Returns:current Cassandra client instance
/** * Execute the query and provide a handler for consuming results. * @param query the query to execute * @return current Cassandra client instance */
public io.reactivex.Single<io.vertx.reactivex.cassandra.ResultSet> rxExecute(String query) { return AsyncResultSingle.toSingle($handler -> { execute(query, $handler); }); }
Executes the given SQL SELECT statement which returns the results of the query as a read stream.
Params:
  • sql – the SQL to execute. For example SELECT * FROM table ....
  • rowStreamHandler – the handler which is called once the operation completes. It will return an instance of CassandraRowStream.
Returns:current Cassandra client instance
/** * Executes the given SQL <code>SELECT</code> statement which returns the results of the query as a read stream. * @param sql the SQL to execute. For example <code>SELECT * FROM table ...</code>. * @param rowStreamHandler the handler which is called once the operation completes. It will return an instance of {@link io.vertx.reactivex.cassandra.CassandraRowStream}. * @return current Cassandra client instance */
public io.vertx.reactivex.cassandra.CassandraClient queryStream(String sql, Handler<AsyncResult<io.vertx.reactivex.cassandra.CassandraRowStream>> rowStreamHandler) { delegate.queryStream(sql, new Handler<AsyncResult<io.vertx.cassandra.CassandraRowStream>>() { public void handle(AsyncResult<io.vertx.cassandra.CassandraRowStream> ar) { if (ar.succeeded()) { rowStreamHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.reactivex.cassandra.CassandraRowStream.newInstance((io.vertx.cassandra.CassandraRowStream)ar.result()))); } else { rowStreamHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
Executes the given SQL SELECT statement which returns the results of the query as a read stream.
Params:
  • sql – the SQL to execute. For example SELECT * FROM table ....
Returns:current Cassandra client instance
/** * Executes the given SQL <code>SELECT</code> statement which returns the results of the query as a read stream. * @param sql the SQL to execute. For example <code>SELECT * FROM table ...</code>. * @return current Cassandra client instance */
public io.vertx.reactivex.cassandra.CassandraClient queryStream(String sql) { return queryStream(sql, ar -> { }); }
Executes the given SQL SELECT statement which returns the results of the query as a read stream.
Params:
  • sql – the SQL to execute. For example SELECT * FROM table ....
Returns:current Cassandra client instance
/** * Executes the given SQL <code>SELECT</code> statement which returns the results of the query as a read stream. * @param sql the SQL to execute. For example <code>SELECT * FROM table ...</code>. * @return current Cassandra client instance */
public io.reactivex.Single<io.vertx.reactivex.cassandra.CassandraRowStream> rxQueryStream(String sql) { return AsyncResultSingle.toSingle($handler -> { queryStream(sql, $handler); }); }
Closes this client.
Params:
  • closeHandler – handler called when client is closed
Returns:current Cassandra client instance
/** * Closes this client. * @param closeHandler handler called when client is closed * @return current Cassandra client instance */
public io.vertx.reactivex.cassandra.CassandraClient close(Handler<AsyncResult<Void>> closeHandler) { delegate.close(closeHandler); return this; }
Closes this client.
Returns:current Cassandra client instance
/** * Closes this client. * @return current Cassandra client instance */
public io.vertx.reactivex.cassandra.CassandraClient close() { return close(ar -> { }); }
Closes this client.
Returns:current Cassandra client instance
/** * Closes this client. * @return current Cassandra client instance */
public io.reactivex.Completable rxClose() { return AsyncResultCompletable.toCompletable($handler -> { close($handler); }); }
Execute the query and provide a handler for consuming results.
Params:
  • query – the query to execute
  • resultHandler – handler called when result of execution is fully fetched.
Returns:current Cassandra client instance
/** * Execute the query and provide a handler for consuming results. * @param query the query to execute * @param resultHandler handler called when result of execution is fully fetched. * @return current Cassandra client instance */
public io.vertx.reactivex.cassandra.CassandraClient executeWithFullFetch(String query, Handler<AsyncResult<List<com.datastax.oss.driver.api.core.cql.Row>>> resultHandler) { delegate.executeWithFullFetch(query, resultHandler); return this; }
Execute the query and provide a handler for consuming results.
Params:
  • query – the query to execute
Returns:current Cassandra client instance
/** * Execute the query and provide a handler for consuming results. * @param query the query to execute * @return current Cassandra client instance */
public io.vertx.reactivex.cassandra.CassandraClient executeWithFullFetch(String query) { return executeWithFullFetch(query, ar -> { }); }
Execute the query and provide a handler for consuming results.
Params:
  • query – the query to execute
Returns:current Cassandra client instance
/** * Execute the query and provide a handler for consuming results. * @param query the query to execute * @return current Cassandra client instance */
public io.reactivex.Single<List<com.datastax.oss.driver.api.core.cql.Row>> rxExecuteWithFullFetch(String query) { return AsyncResultSingle.toSingle($handler -> { executeWithFullFetch(query, $handler); }); }
Execute the query and provide a handler for consuming results.
Params:
  • statement – the statement to execute
  • resultHandler – handler called when result of execution is fully fetched.
Returns:current Cassandra client instance
/** * Execute the query and provide a handler for consuming results. * @param statement the statement to execute * @param resultHandler handler called when result of execution is fully fetched. * @return current Cassandra client instance */
public io.vertx.reactivex.cassandra.CassandraClient executeWithFullFetch(com.datastax.oss.driver.api.core.cql.Statement statement, Handler<AsyncResult<List<com.datastax.oss.driver.api.core.cql.Row>>> resultHandler) { delegate.executeWithFullFetch(statement, resultHandler); return this; }
Execute the query and provide a handler for consuming results.
Params:
  • statement – the statement to execute
Returns:current Cassandra client instance
/** * Execute the query and provide a handler for consuming results. * @param statement the statement to execute * @return current Cassandra client instance */
public io.vertx.reactivex.cassandra.CassandraClient executeWithFullFetch(com.datastax.oss.driver.api.core.cql.Statement statement) { return executeWithFullFetch(statement, ar -> { }); }
Execute the query and provide a handler for consuming results.
Params:
  • statement – the statement to execute
Returns:current Cassandra client instance
/** * Execute the query and provide a handler for consuming results. * @param statement the statement to execute * @return current Cassandra client instance */
public io.reactivex.Single<List<com.datastax.oss.driver.api.core.cql.Row>> rxExecuteWithFullFetch(com.datastax.oss.driver.api.core.cql.Statement statement) { return AsyncResultSingle.toSingle($handler -> { executeWithFullFetch(statement, $handler); }); }
Execute the statement and provide a handler for consuming results.
Params:
  • statement – the statement to execute
  • resultHandler – handler called when result of execution is present
Returns:current Cassandra client instance
/** * Execute the statement and provide a handler for consuming results. * @param statement the statement to execute * @param resultHandler handler called when result of execution is present * @return current Cassandra client instance */
public io.vertx.reactivex.cassandra.CassandraClient execute(com.datastax.oss.driver.api.core.cql.Statement statement, Handler<AsyncResult<io.vertx.reactivex.cassandra.ResultSet>> resultHandler) { delegate.execute(statement, new Handler<AsyncResult<io.vertx.cassandra.ResultSet>>() { public void handle(AsyncResult<io.vertx.cassandra.ResultSet> ar) { if (ar.succeeded()) { resultHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.reactivex.cassandra.ResultSet.newInstance((io.vertx.cassandra.ResultSet)ar.result()))); } else { resultHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
Execute the statement and provide a handler for consuming results.
Params:
  • statement – the statement to execute
Returns:current Cassandra client instance
/** * Execute the statement and provide a handler for consuming results. * @param statement the statement to execute * @return current Cassandra client instance */
public io.vertx.reactivex.cassandra.CassandraClient execute(com.datastax.oss.driver.api.core.cql.Statement statement) { return execute(statement, ar -> { }); }
Execute the statement and provide a handler for consuming results.
Params:
  • statement – the statement to execute
Returns:current Cassandra client instance
/** * Execute the statement and provide a handler for consuming results. * @param statement the statement to execute * @return current Cassandra client instance */
public io.reactivex.Single<io.vertx.reactivex.cassandra.ResultSet> rxExecute(com.datastax.oss.driver.api.core.cql.Statement statement) { return AsyncResultSingle.toSingle($handler -> { execute(statement, $handler); }); }
Prepares the provided query string.
Params:
  • query – the query to prepare
  • resultHandler – handler called when result of query preparation is present
Returns:current Cassandra client instance
/** * Prepares the provided query string. * @param query the query to prepare * @param resultHandler handler called when result of query preparation is present * @return current Cassandra client instance */
public io.vertx.reactivex.cassandra.CassandraClient prepare(String query, Handler<AsyncResult<com.datastax.oss.driver.api.core.cql.PreparedStatement>> resultHandler) { delegate.prepare(query, resultHandler); return this; }
Prepares the provided query string.
Params:
  • query – the query to prepare
Returns:current Cassandra client instance
/** * Prepares the provided query string. * @param query the query to prepare * @return current Cassandra client instance */
public io.vertx.reactivex.cassandra.CassandraClient prepare(String query) { return prepare(query, ar -> { }); }
Prepares the provided query string.
Params:
  • query – the query to prepare
Returns:current Cassandra client instance
/** * Prepares the provided query string. * @param query the query to prepare * @return current Cassandra client instance */
public io.reactivex.Single<com.datastax.oss.driver.api.core.cql.PreparedStatement> rxPrepare(String query) { return AsyncResultSingle.toSingle($handler -> { prepare(query, $handler); }); }
Prepares the provided a .
Params:
  • statement – the statement to prepare
  • resultHandler – handler called when result of query preparation is present
Returns:current Cassandra client instance
/** * Prepares the provided a . * @param statement the statement to prepare * @param resultHandler handler called when result of query preparation is present * @return current Cassandra client instance */
public io.vertx.reactivex.cassandra.CassandraClient prepare(com.datastax.oss.driver.api.core.cql.SimpleStatement statement, Handler<AsyncResult<com.datastax.oss.driver.api.core.cql.PreparedStatement>> resultHandler) { delegate.prepare(statement, resultHandler); return this; }
Prepares the provided a .
Params:
  • statement – the statement to prepare
Returns:current Cassandra client instance
/** * Prepares the provided a . * @param statement the statement to prepare * @return current Cassandra client instance */
public io.vertx.reactivex.cassandra.CassandraClient prepare(com.datastax.oss.driver.api.core.cql.SimpleStatement statement) { return prepare(statement, ar -> { }); }
Prepares the provided a .
Params:
  • statement – the statement to prepare
Returns:current Cassandra client instance
/** * Prepares the provided a . * @param statement the statement to prepare * @return current Cassandra client instance */
public io.reactivex.Single<com.datastax.oss.driver.api.core.cql.PreparedStatement> rxPrepare(com.datastax.oss.driver.api.core.cql.SimpleStatement statement) { return AsyncResultSingle.toSingle($handler -> { prepare(statement, $handler); }); }
Executes the given SQL statement which returns the results of the query as a read stream.
Params:
  • statement – the statement to execute.
  • rowStreamHandler – the handler which is called once the operation completes. It will return an instance of CassandraRowStream.
Returns:current Cassandra client instance
/** * Executes the given SQL statement which returns the results of the query as a read stream. * @param statement the statement to execute. * @param rowStreamHandler the handler which is called once the operation completes. It will return an instance of {@link io.vertx.reactivex.cassandra.CassandraRowStream}. * @return current Cassandra client instance */
public io.vertx.reactivex.cassandra.CassandraClient queryStream(com.datastax.oss.driver.api.core.cql.Statement statement, Handler<AsyncResult<io.vertx.reactivex.cassandra.CassandraRowStream>> rowStreamHandler) { delegate.queryStream(statement, new Handler<AsyncResult<io.vertx.cassandra.CassandraRowStream>>() { public void handle(AsyncResult<io.vertx.cassandra.CassandraRowStream> ar) { if (ar.succeeded()) { rowStreamHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.reactivex.cassandra.CassandraRowStream.newInstance((io.vertx.cassandra.CassandraRowStream)ar.result()))); } else { rowStreamHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
Executes the given SQL statement which returns the results of the query as a read stream.
Params:
  • statement – the statement to execute.
Returns:current Cassandra client instance
/** * Executes the given SQL statement which returns the results of the query as a read stream. * @param statement the statement to execute. * @return current Cassandra client instance */
public io.vertx.reactivex.cassandra.CassandraClient queryStream(com.datastax.oss.driver.api.core.cql.Statement statement) { return queryStream(statement, ar -> { }); }
Executes the given SQL statement which returns the results of the query as a read stream.
Params:
  • statement – the statement to execute.
Returns:current Cassandra client instance
/** * Executes the given SQL statement which returns the results of the query as a read stream. * @param statement the statement to execute. * @return current Cassandra client instance */
public io.reactivex.Single<io.vertx.reactivex.cassandra.CassandraRowStream> rxQueryStream(com.datastax.oss.driver.api.core.cql.Statement statement) { return AsyncResultSingle.toSingle($handler -> { queryStream(statement, $handler); }); }
Get for the session.
Params:
  • handler – the handler called backed with the metadata
/** * Get for the session. * @param handler the handler called backed with the metadata */
public void metadata(Handler<AsyncResult<com.datastax.oss.driver.api.core.metadata.Metadata>> handler) { delegate.metadata(handler); }
Get for the session.
/** * Get for the session. */
public void metadata() { metadata(ar -> { }); }
Get for the session.
Returns:
/** * Get for the session. * @return */
public io.reactivex.Single<com.datastax.oss.driver.api.core.metadata.Metadata> rxMetadata() { return AsyncResultSingle.toSingle($handler -> { metadata($handler); }); }
The default shared client name.
/** * The default shared client name. */
public static final String DEFAULT_SHARED_CLIENT_NAME = io.vertx.cassandra.CassandraClient.DEFAULT_SHARED_CLIENT_NAME; public static CassandraClient newInstance(io.vertx.cassandra.CassandraClient arg) { return arg != null ? new CassandraClient(arg) : null; } }