DATACASS-555 - Polishing.
Add Javadoc. Tweak Javadoc for consistency. Refactor SimpleReactivePreparedStatementCreator into newReactivePreparedStatementCreator(…) method. Reformat code. Original pull request: #133.
This commit is contained in:
@@ -740,7 +740,7 @@ public class AsyncCqlTemplate extends CassandraAccessor implements AsyncCqlOpera
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create a new CQL-based AsyncPreparedStatementCreator using the CQL passed in. By default, we'll create an
|
||||
* Create a new CQL-based {@link AsyncPreparedStatementCreator} using the CQL passed in. By default, we'll create an
|
||||
* {@link SimpleAsyncPreparedStatementCreator}. This method allows for the creation to be overridden by subclasses.
|
||||
*
|
||||
* @param cql static CQL to execute, must not be empty or {@literal null}.
|
||||
|
||||
@@ -69,8 +69,7 @@ import com.datastax.driver.core.exceptions.DriverException;
|
||||
* @author Antoine Toulme
|
||||
* @author John Blum
|
||||
* @author Mark Paluch
|
||||
* @author Mike Barlotta (CodeSmell)
|
||||
*
|
||||
* @author Mike Barlotta
|
||||
* @see PreparedStatementCreator
|
||||
* @see PreparedStatementBinder
|
||||
* @see PreparedStatementCallback
|
||||
@@ -406,7 +405,7 @@ public class CqlTemplate extends CassandraAccessor implements CqlOperations {
|
||||
@Override
|
||||
public boolean execute(String cql, @Nullable PreparedStatementBinder psb) throws DataAccessException {
|
||||
// noinspection ConstantConditions
|
||||
return query(newPreparedStatementCreator(cql), psb, ResultSet::wasApplied);
|
||||
return query(newPreparedStatementCreator(cql), psb, ResultSet::wasApplied);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -705,15 +704,21 @@ public class CqlTemplate extends CassandraAccessor implements CqlOperations {
|
||||
return getCurrentSession().getCluster().getMetadata().getAllHosts();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected PreparedStatementCreator newPreparedStatementCreator(String cql) {
|
||||
return new SimplePreparedStatementCreator(cql);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Implementation hooks and helper methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create a new CQL-based {@link PreparedStatementCreator} using the CQL passed in. By default, we'll create an
|
||||
* {@link SimplePreparedStatementCreator}. This method allows for the creation to be overridden by subclasses.
|
||||
*
|
||||
* @param cql static CQL to execute, must not be empty or {@literal null}.
|
||||
* @return the new {@link PreparedStatementCreator} to use
|
||||
*/
|
||||
protected PreparedStatementCreator newPreparedStatementCreator(String cql) {
|
||||
return new SimplePreparedStatementCreator(cql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the given {@link DriverException} into a generic {@link DataAccessException}.
|
||||
*
|
||||
|
||||
@@ -470,7 +470,7 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
|
||||
*/
|
||||
@Override
|
||||
public <T> Flux<T> execute(String cql, ReactivePreparedStatementCallback<T> action) throws DataAccessException {
|
||||
return execute(new SimpleReactivePreparedStatementCreator(cql), action);
|
||||
return execute(newReactivePreparedStatementCreator(cql), action);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -520,7 +520,7 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
|
||||
@Override
|
||||
public <T> Flux<T> query(String cql, @Nullable PreparedStatementBinder psb, ReactiveResultSetExtractor<T> rse)
|
||||
throws DataAccessException {
|
||||
return query(new SimpleReactivePreparedStatementCreator(cql), psb, rse);
|
||||
return query(newReactivePreparedStatementCreator(cql), psb, rse);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -528,7 +528,7 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
|
||||
*/
|
||||
@Override
|
||||
public <T> Flux<T> query(String cql, ReactiveResultSetExtractor<T> rse, Object... args) throws DataAccessException {
|
||||
return query(new SimpleReactivePreparedStatementCreator(cql), newArgPreparedStatementBinder(args), rse);
|
||||
return query(newReactivePreparedStatementCreator(cql), newArgPreparedStatementBinder(args), rse);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -615,7 +615,7 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
|
||||
|
||||
Assert.hasText(cql, "CQL must not be empty");
|
||||
|
||||
return query(new SimpleReactivePreparedStatementCreator(cql), newArgPreparedStatementBinder(args), Mono::just)
|
||||
return query(newReactivePreparedStatementCreator(cql), newArgPreparedStatementBinder(args), Mono::just)
|
||||
.next();
|
||||
}
|
||||
|
||||
@@ -641,7 +641,7 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
|
||||
*/
|
||||
@Override
|
||||
public Mono<Boolean> execute(String cql, @Nullable PreparedStatementBinder psb) throws DataAccessException {
|
||||
return query(new SimpleReactivePreparedStatementCreator(cql), psb, resultSet -> Mono.just(resultSet.wasApplied()))
|
||||
return query(newReactivePreparedStatementCreator(cql), psb, resultSet -> Mono.just(resultSet.wasApplied()))
|
||||
.next();
|
||||
}
|
||||
|
||||
@@ -661,9 +661,7 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
|
||||
|
||||
Assert.notNull(args, "Args Publisher must not be null");
|
||||
|
||||
SimpleReactivePreparedStatementCreator psc = new SimpleReactivePreparedStatementCreator(cql);
|
||||
|
||||
return execute(psc, (session, ps) -> Flux.from(args).flatMap(objects -> {
|
||||
return execute(newReactivePreparedStatementCreator(cql), (session, ps) -> Flux.from(args).flatMap(objects -> {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Executing Prepared CQL Statement [{}]", cql);
|
||||
@@ -682,6 +680,19 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
|
||||
// Implementation hooks and helper methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create a new CQL-based {@link ReactivePreparedStatementCreator} using the CQL passed in. By default, we'll create
|
||||
* an {@link SimpleReactivePreparedStatementCreator}. This method allows for the creation to be overridden by
|
||||
* subclasses.
|
||||
*
|
||||
* @param cql static CQL to execute, must not be empty or {@literal null}.
|
||||
* @return the new {@link ReactivePreparedStatementCreator} to use
|
||||
* @since 2.0.8
|
||||
*/
|
||||
protected ReactivePreparedStatementCreator newReactivePreparedStatementCreator(String cql) {
|
||||
return new SimpleReactivePreparedStatementCreator(cql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a reusable {@link Flux} given a {@link ReactiveStatementCallback} without exception translation.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user