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

io.vertx.rxjava.cassandra.CassandraClient Maven / Gradle / Ivy

There is a newer version: 5.0.0.CR2
Show newest version
/*
 * 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.cassandra;

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.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 {@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 __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 {@link io.vertx.rxjava.cassandra.CassandraClient#create} with default options. * @param vertx * @return */ public static io.vertx.rxjava.cassandra.CassandraClient create(io.vertx.rxjava.core.Vertx vertx) { io.vertx.rxjava.cassandra.CassandraClient ret = io.vertx.rxjava.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. * @param vertx the Vert.x instance * @param options the options * @return the client */ public static io.vertx.rxjava.cassandra.CassandraClient create(io.vertx.rxjava.core.Vertx vertx, io.vertx.cassandra.CassandraClientOptions options) { io.vertx.rxjava.cassandra.CassandraClient ret = io.vertx.rxjava.cassandra.CassandraClient.newInstance((io.vertx.cassandra.CassandraClient)io.vertx.cassandra.CassandraClient.create(vertx.getDelegate(), options)); return ret; } /** * Like {@link io.vertx.rxjava.cassandra.CassandraClient#createShared} with default options and client name. * @param vertx * @return */ public static io.vertx.rxjava.cassandra.CassandraClient createShared(io.vertx.rxjava.core.Vertx vertx) { io.vertx.rxjava.cassandra.CassandraClient ret = io.vertx.rxjava.cassandra.CassandraClient.newInstance((io.vertx.cassandra.CassandraClient)io.vertx.cassandra.CassandraClient.createShared(vertx.getDelegate())); return ret; } /** * Like {@link io.vertx.rxjava.cassandra.CassandraClient#createShared} with default options. * @param vertx * @param clientName * @return */ public static io.vertx.rxjava.cassandra.CassandraClient createShared(io.vertx.rxjava.core.Vertx vertx, String clientName) { io.vertx.rxjava.cassandra.CassandraClient ret = io.vertx.rxjava.cassandra.CassandraClient.newInstance((io.vertx.cassandra.CassandraClient)io.vertx.cassandra.CassandraClient.createShared(vertx.getDelegate(), clientName)); return ret; } /** * Like {@link io.vertx.rxjava.cassandra.CassandraClient#createShared} with default client name. * @param vertx * @param options * @return */ public static io.vertx.rxjava.cassandra.CassandraClient createShared(io.vertx.rxjava.core.Vertx vertx, io.vertx.cassandra.CassandraClientOptions options) { io.vertx.rxjava.cassandra.CassandraClient ret = io.vertx.rxjava.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. * @param vertx the Vert.x instance * @param clientName the shared client name * @param options the options * @return the client */ public static io.vertx.rxjava.cassandra.CassandraClient createShared(io.vertx.rxjava.core.Vertx vertx, String clientName, io.vertx.cassandra.CassandraClientOptions options) { io.vertx.rxjava.cassandra.CassandraClient ret = io.vertx.rxjava.cassandra.CassandraClient.newInstance((io.vertx.cassandra.CassandraClient)io.vertx.cassandra.CassandraClient.createShared(vertx.getDelegate(), clientName, options)); return ret; } /** * @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. * @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.rxjava.cassandra.CassandraClient execute(String query, Handler> resultHandler) { delegate.execute(query, new Handler>() { public void handle(AsyncResult ar) { if (ar.succeeded()) { resultHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.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. * @param query the query to execute * @return current Cassandra client instance */ public io.vertx.rxjava.cassandra.CassandraClient execute(String query) { return execute(query, ar -> { }); } /** * Execute the query and provide a handler for consuming results. * @param query the query to execute * @return current Cassandra client instance */ public Single rxExecute(String query) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { execute(query, fut); })); } /** * Executes the given SQL SELECT statement which returns the results of the query as a read stream. * @param sql the SQL to execute. For example SELECT * FROM table .... * @param rowStreamHandler the handler which is called once the operation completes. It will return an instance of {@link io.vertx.rxjava.cassandra.CassandraRowStream}. * @return current Cassandra client instance */ public io.vertx.rxjava.cassandra.CassandraClient queryStream(String sql, Handler> rowStreamHandler) { delegate.queryStream(sql, new Handler>() { public void handle(AsyncResult ar) { if (ar.succeeded()) { rowStreamHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.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. * @param sql the SQL to execute. For example SELECT * FROM table .... * @return current Cassandra client instance */ public io.vertx.rxjava.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. * @param sql the SQL to execute. For example SELECT * FROM table .... * @return current Cassandra client instance */ public Single rxQueryStream(String sql) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { queryStream(sql, fut); })); } /** * Closes this client. * @param closeHandler handler called when client is closed * @return current Cassandra client instance */ public io.vertx.rxjava.cassandra.CassandraClient close(Handler> closeHandler) { delegate.close(closeHandler); return this; } /** * Closes this client. * @return current Cassandra client instance */ public io.vertx.rxjava.cassandra.CassandraClient close() { return close(ar -> { }); } /** * Closes this client. * @return current Cassandra client instance */ public Single rxClose() { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { close(fut); })); } /** * 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.rxjava.cassandra.CassandraClient executeWithFullFetch(String query, Handler>> resultHandler) { delegate.executeWithFullFetch(query, resultHandler); return this; } /** * Execute the query and provide a handler for consuming results. * @param query the query to execute * @return current Cassandra client instance */ public io.vertx.rxjava.cassandra.CassandraClient executeWithFullFetch(String query) { return executeWithFullFetch(query, ar -> { }); } /** * Execute the query and provide a handler for consuming results. * @param query the query to execute * @return current Cassandra client instance */ public Single> rxExecuteWithFullFetch(String query) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { executeWithFullFetch(query, fut); })); } /** * 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.rxjava.cassandra.CassandraClient executeWithFullFetch(com.datastax.oss.driver.api.core.cql.Statement statement, Handler>> resultHandler) { delegate.executeWithFullFetch(statement, resultHandler); return this; } /** * Execute the query and provide a handler for consuming results. * @param statement the statement to execute * @return current Cassandra client instance */ public io.vertx.rxjava.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. * @param statement the statement to execute * @return current Cassandra client instance */ public Single> rxExecuteWithFullFetch(com.datastax.oss.driver.api.core.cql.Statement statement) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { executeWithFullFetch(statement, fut); })); } /** * 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.rxjava.cassandra.CassandraClient execute(com.datastax.oss.driver.api.core.cql.Statement statement, Handler> resultHandler) { delegate.execute(statement, new Handler>() { public void handle(AsyncResult ar) { if (ar.succeeded()) { resultHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.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. * @param statement the statement to execute * @return current Cassandra client instance */ public io.vertx.rxjava.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. * @param statement the statement to execute * @return current Cassandra client instance */ public Single rxExecute(com.datastax.oss.driver.api.core.cql.Statement statement) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { execute(statement, fut); })); } /** * 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.rxjava.cassandra.CassandraClient prepare(String query, Handler> resultHandler) { delegate.prepare(query, resultHandler); return this; } /** * Prepares the provided query string. * @param query the query to prepare * @return current Cassandra client instance */ public io.vertx.rxjava.cassandra.CassandraClient prepare(String query) { return prepare(query, ar -> { }); } /** * Prepares the provided query string. * @param query the query to prepare * @return current Cassandra client instance */ public Single rxPrepare(String query) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { prepare(query, fut); })); } /** * 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.rxjava.cassandra.CassandraClient prepare(com.datastax.oss.driver.api.core.cql.SimpleStatement statement, Handler> resultHandler) { delegate.prepare(statement, resultHandler); return this; } /** * Prepares the provided a . * @param statement the statement to prepare * @return current Cassandra client instance */ public io.vertx.rxjava.cassandra.CassandraClient prepare(com.datastax.oss.driver.api.core.cql.SimpleStatement statement) { return prepare(statement, ar -> { }); } /** * Prepares the provided a . * @param statement the statement to prepare * @return current Cassandra client instance */ public Single rxPrepare(com.datastax.oss.driver.api.core.cql.SimpleStatement statement) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { prepare(statement, fut); })); } /** * 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.rxjava.cassandra.CassandraRowStream}. * @return current Cassandra client instance */ public io.vertx.rxjava.cassandra.CassandraClient queryStream(com.datastax.oss.driver.api.core.cql.Statement statement, Handler> rowStreamHandler) { delegate.queryStream(statement, new Handler>() { public void handle(AsyncResult ar) { if (ar.succeeded()) { rowStreamHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.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. * @param statement the statement to execute. * @return current Cassandra client instance */ public io.vertx.rxjava.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. * @param statement the statement to execute. * @return current Cassandra client instance */ public Single rxQueryStream(com.datastax.oss.driver.api.core.cql.Statement statement) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { queryStream(statement, fut); })); } /** * Get for the session. * @return */ public io.vertx.rxjava.core.Future metadata() { io.vertx.rxjava.core.Future ret = io.vertx.rxjava.core.Future.newInstance((io.vertx.core.Future)delegate.metadata(), TypeArg.unknown()); return ret; } /** * 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; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy