DATACASS-393 - Polishing.

Add override comments. Fix JavaDoc. Reformat code.
This commit is contained in:
Mark Paluch
2017-01-31 09:43:45 +01:00
parent bc5262d633
commit 7e33bf3bcf
75 changed files with 672 additions and 347 deletions

View File

@@ -1,12 +1,12 @@
/*
* Copyright 2013-2014 the original author or authors.
*
*
* Licensed 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.
@@ -38,25 +38,33 @@ import org.springframework.util.Assert;
* A single keyspace XML Element can result in multiple actions. Example: {@literal CREATE_DROP}. This FactoryBean
* inspects the action required to satisfy the keyspace element, and then returns a Set of atomic
* {@link KeyspaceActionSpecification} required to satisfy the configuration action.
*
*
* @author David Webb
*/
public class KeyspaceActionSpecificationFactoryBean implements FactoryBean<Set<KeyspaceActionSpecification<?>>>,
InitializingBean, DisposableBean {
private KeyspaceAction action;
private String name;
private List<String> networkTopologyDataCenters = new LinkedList<String>();
private List<String> networkTopologyReplicationFactors = new LinkedList<String>();
private ReplicationStrategy replicationStrategy;
private long replicationFactor;
private boolean durableWrites = false;
private boolean ifNotExists = false;
private Set<KeyspaceActionSpecification<?>> specs = new HashSet<KeyspaceActionSpecification<?>>();
@Override
public void destroy() throws Exception {
action = null;
name = null;
networkTopologyDataCenters = null;
@@ -86,7 +94,7 @@ public class KeyspaceActionSpecificationFactoryBean implements FactoryBean<Set<K
/**
* Generate a {@link CreateKeyspaceSpecification} for the keyspace.
*
*
* @return The {@link CreateKeyspaceSpecification}
*/
private CreateKeyspaceSpecification generateCreateKeyspaceSpecification() {
@@ -118,7 +126,7 @@ public class KeyspaceActionSpecificationFactoryBean implements FactoryBean<Set<K
/**
* Generate a {@link DropKeyspaceSpecification} for the keyspace.
*
*
* @return The {@link DropKeyspaceSpecification}
*/
private DropKeyspaceSpecification generateDropKeyspaceSpecification() {

View File

@@ -15,6 +15,11 @@
*/
package org.springframework.cassandra.core;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Scheduler;
import reactor.core.scheduler.Schedulers;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
@@ -23,24 +28,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.ColumnDefinitions;
import com.datastax.driver.core.ExecutionInfo;
import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.RegularStatement;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.ResultSetFuture;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.SimpleStatement;
import com.datastax.driver.core.Statement;
import com.datastax.driver.core.*;
import com.google.common.util.concurrent.ListenableFuture;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Scheduler;
import reactor.core.scheduler.Schedulers;
/**
* Default implementation of a {@link ReactiveSession}. This implementation bridges asynchronous {@link Session} methods
* to reactive execution patterns.
@@ -72,7 +62,7 @@ public class DefaultBridgedReactiveSession implements ReactiveSession {
private final Scheduler scheduler;
/**
* Creates a new {@link DefaultBridgedReactiveSession} for a {@link Session} and {@link Scheduler}.
* Create a new {@link DefaultBridgedReactiveSession} for a {@link Session} and {@link Scheduler}.
*
* @param session must not be {@literal null}.
* @param scheduler must not be {@literal null}.

View File

@@ -59,7 +59,7 @@ public class QueryOptions {
}
/**
* Creates a new {@link QueryOptionsBuilder}.
* Create a new {@link QueryOptionsBuilder}.
*
* @return a new {@link QueryOptionsBuilder}.
* @since 1.5

View File

@@ -74,7 +74,6 @@ import com.datastax.driver.core.querybuilder.QueryBuilder;
* @see RowMapper
* @see org.springframework.dao.support.PersistenceExceptionTranslator
*/
@SuppressWarnings("WeakerAccess")
public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements ReactiveCqlOperations {
/**
@@ -253,8 +252,8 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
*/
@Override
public <T> Mono<T> queryForObject(String cql, RowMapper<T> rowMapper) throws DataAccessException {
return query(cql, rowMapper).buffer(2).flatMap(
list -> Mono.just(DataAccessUtils.requiredSingleResult(list))).next();
return query(cql, rowMapper).buffer(2).flatMap(list -> Mono.just(DataAccessUtils.requiredSingleResult(list)))
.next();
}
/* (non-Javadoc)
@@ -374,8 +373,8 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
*/
@Override
public <T> Mono<T> queryForObject(Statement statement, RowMapper<T> rowMapper) throws DataAccessException {
return query(statement, rowMapper).buffer(2).flatMap(
list -> Mono.just(DataAccessUtils.requiredSingleResult(list))).next();
return query(statement, rowMapper).buffer(2).flatMap(list -> Mono.just(DataAccessUtils.requiredSingleResult(list)))
.next();
}
/* (non-Javadoc)
@@ -470,8 +469,8 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
* Query using a prepared statement, reading the {@link ReactiveResultSet} with a {@link ReactiveResultSetExtractor}.
*
* @param psc object that can create a {@link PreparedStatement} given a {@link ReactiveSession}
* @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is {@literal null}, the CQL will
* be assumed to contain no bind parameters.
* @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is
* {@literal null}, the CQL will be assumed to contain no bind parameters.
* @param rse object that will extract results
* @return an arbitrary result object, as returned by the {@link ReactiveResultSetExtractor}
* @throws DataAccessException if there is any problem
@@ -488,8 +487,8 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
logger.debug("Executing Prepared CQL Statement [{}]", ps.getQueryString());
}
BoundStatement boundStatement = (preparedStatementBinder != null
? preparedStatementBinder.bindValues(ps) : ps.bind());
BoundStatement boundStatement = (preparedStatementBinder != null ? preparedStatementBinder.bindValues(ps)
: ps.bind());
applyStatementSettings(boundStatement);
@@ -564,8 +563,8 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
*/
@Override
public <T> Mono<T> queryForObject(String cql, RowMapper<T> rowMapper, Object... args) throws DataAccessException {
return query(cql, rowMapper, args).buffer(2).flatMap(
list -> Mono.just(DataAccessUtils.requiredSingleResult(list))).next();
return query(cql, rowMapper, args).buffer(2).flatMap(list -> Mono.just(DataAccessUtils.requiredSingleResult(list)))
.next();
}
/* (non-Javadoc)
@@ -634,8 +633,8 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
*/
@Override
public Mono<Boolean> execute(String cql, PreparedStatementBinder psb) throws DataAccessException {
return query(new SimpleReactivePreparedStatementCreator(cql), psb,
resultSet -> Mono.just(resultSet.wasApplied())).next();
return query(new SimpleReactivePreparedStatementCreator(cql), psb, resultSet -> Mono.just(resultSet.wasApplied()))
.next();
}
/* (non-Javadoc)
@@ -728,11 +727,10 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
*
* @return the exception translation {@link Function}
*/
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
protected <T> Function<Throwable, Mono<? extends T>> translateException() {
return throwable -> Mono.error(throwable instanceof DriverException
? translateExceptionIfPossible((DriverException) throwable) : throwable);
return throwable -> Mono.error(
throwable instanceof DriverException ? translateExceptionIfPossible((DriverException) throwable) : throwable);
}
/**
@@ -743,11 +741,10 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
* @return the exception translation {@link Function}
* @see CqlProvider
*/
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
protected <T> Function<Throwable, Mono<? extends T>> translateException(String task, String cql) {
return throwable -> Mono.error(throwable instanceof DriverException
? translate(task, cql, (DriverException) throwable) : throwable);
return throwable -> Mono
.error(throwable instanceof DriverException ? translate(task, cql, (DriverException) throwable) : throwable);
}
/**

View File

@@ -15,6 +15,9 @@
*/
package org.springframework.cassandra.core;
import java.util.HashSet;
import java.util.Set;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -24,56 +27,30 @@ import org.springframework.util.StringUtils;
* @see <a href=
* "http://cassandra.apache.org/doc/cql3/CQL.html#appendixA">http://cassandra.apache.org/doc/cql3/CQL.html#appendixA</a>
* @author Matthew T. Adams
* @author Mark Paluch
*/
public enum ReservedKeyword {
ADD,
ALTER,
AND,
ANY,
APPLY,
ASC,
AUTHORIZE,
BATCH,
BEGIN,
BY,
COLUMNFAMILY,
CREATE,
DELETE,
DESC,
DROP,
EACH_QUORUM,
FROM,
GRANT,
IN,
INDEX,
INSERT,
INTO,
KEYSPACE,
LIMIT,
LOCAL_ONE,
LOCAL_QUORUM,
MODIFY,
NORECURSIVE,
OF,
ON,
ONE,
ORDER,
PRIMARY,
QUORUM,
REVOKE,
SCHEMA,
SELECT,
SET,
TABLE,
THREE,
TOKEN,
TRUNCATE,
TWO,
UPDATE,
USE,
USING,
WHERE,
WITH;
ADD, ALTER, AND, ANY, APPLY, ASC, AUTHORIZE, //
BATCH, BEGIN, BY, COLUMNFAMILY, CREATE, DELETE, DESC, DROP, EACH_QUORUM, //
FROM, GRANT, IN, INDEX, INSERT, INTO, KEYSPACE, //
LIMIT, LOCAL_ONE, LOCAL_QUORUM, MODIFY, NORECURSIVE, //
OF, ON, ONE, ORDER, PRIMARY, QUORUM, REVOKE, SCHEMA, SELECT, SET, //
TABLE, THREE, TOKEN, TRUNCATE, TWO, UPDATE, USE, USING, WHERE, WITH;
private final static Set<String> RESERVED;
static {
RESERVED = new HashSet<>();
for (ReservedKeyword keyword : ReservedKeyword.values()) {
RESERVED.add(keyword.name());
}
}
/**
* @see ReservedKeyword#isReserved(String)
@@ -87,6 +64,8 @@ public enum ReservedKeyword {
/**
* Returns whether the given string is a CQL reserved keyword. This comparison is done regardless of case.
*
* @param candidate candidate keyword.
*/
public static boolean isReserved(String candidate) {
@@ -94,11 +73,6 @@ public enum ReservedKeyword {
return false;
}
try {
Enum.valueOf(ReservedKeyword.class, candidate.toUpperCase());
return true;
} catch (IllegalArgumentException x) {
return false;
}
return RESERVED.contains(candidate.toUpperCase());
}
}

View File

@@ -57,7 +57,7 @@ public class WriteOptions extends QueryOptions {
}
/**
* Creates a new {@link WriteOptionsBuilder}.
* Create a new {@link WriteOptionsBuilder}.
*
* @return a new {@link WriteOptionsBuilder}.
* @since 1.5

View File

@@ -16,7 +16,6 @@
package org.springframework.cassandra.core.converter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.springframework.core.convert.converter.Converter;
@@ -34,20 +33,36 @@ public class ResultSetToArrayConverter implements Converter<ResultSet, Object[]>
protected Converter<Row, Object[]> rowConverter;
/**
* Create a new {@link ResultSetToArrayConverter} given a row {@link Converter}.
*
* @param rowConverter must not be {@literal null}.
*/
public ResultSetToArrayConverter(Converter<Row, Object[]> rowConverter) {
setRowConverter(rowConverter);
}
/**
* @return the row {@link Converter}.
*/
public Converter<Row, Object[]> getRowConverter() {
return rowConverter;
}
/**
* Set the row {@link Converter}.
*
* @param rowConverter must not be {@literal null}.
*/
public void setRowConverter(Converter<Row, Object[]> rowConverter) {
Assert.notNull(rowConverter, "Converter must not be null");
this.rowConverter = rowConverter;
}
/* (non-Javadoc)
* @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object)
*/
@Override
public Object[] convert(ResultSet resultSet) {
@@ -56,9 +71,8 @@ public class ResultSetToArrayConverter implements Converter<ResultSet, Object[]>
}
List<Object[]> list = new ArrayList<Object[]>();
Iterator<Row> i = resultSet.iterator();
while (i.hasNext()) {
list.add(rowConverter.convert(i.next()));
for (Row row : resultSet) {
list.add(rowConverter.convert(row));
}
return list.toArray();

View File

@@ -16,7 +16,6 @@
package org.springframework.cassandra.core.converter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -33,18 +32,36 @@ import com.datastax.driver.core.Row;
*/
public class ResultSetToListConverter implements Converter<ResultSet, List<Map<String, Object>>> {
protected Converter<Row, Map<String, Object>> rowConverter = new RowToMapConverter();
private Converter<Row, Map<String, Object>> rowConverter;
public ResultSetToListConverter() {}
/**
* Create a new {@link ResultSetToListConverter} using a default {@link RowToMapConverter}.
*/
public ResultSetToListConverter() {
this(new RowToMapConverter());
}
/**
* Create a new {@link ResultSetToListConverter} given a row to map {@link Converter}.
*
* @param rowConverter must not be {@literal null}.
*/
public ResultSetToListConverter(Converter<Row, Map<String, Object>> rowConverter) {
setRowConverter(rowConverter);
}
/**
* @return the row to map {@link Converter}.
*/
public Converter<Row, Map<String, Object>> getRowConverter() {
return rowConverter;
}
/**
* Set the the row to map {@link Converter}.
*
* @param rowConverter must not be {@literal null}.
*/
public void setRowConverter(Converter<Row, Map<String, Object>> rowConverter) {
Assert.notNull(rowConverter, "Converter must not be null");
@@ -52,6 +69,9 @@ public class ResultSetToListConverter implements Converter<ResultSet, List<Map<S
this.rowConverter = rowConverter;
}
/* (non-Javadoc)
* @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object)
*/
@Override
public List<Map<String, Object>> convert(ResultSet resultSet) {
@@ -60,9 +80,8 @@ public class ResultSetToListConverter implements Converter<ResultSet, List<Map<S
}
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Iterator<Row> i = resultSet.iterator();
while (i.hasNext()) {
list.add(rowConverter.convert(i.next()));
for (Row row : resultSet) {
list.add(rowConverter.convert(row));
}
return list;

View File

@@ -26,8 +26,8 @@ import com.datastax.driver.core.TableMetadata;
/**
* This encapsulates the logic for CQL quoted and unquoted identifiers.
*
* <p>CQL identifiers, when unquoted, are converted to lower case. When quoted, they are returned as-is with no lower
* <p>
* CQL identifiers, when unquoted, are converted to lower case. When quoted, they are returned as-is with no lower
* casing and encased in double quotes. To render, use any of the methods {@link #toCql()},
* {@link #toCql(StringBuilder)}, or {@link #toString()}.
*
@@ -44,11 +44,45 @@ public final class CqlIdentifier implements Comparable<CqlIdentifier>, Serializa
private static final long serialVersionUID = -974441606330912437L;
public static final String UNQUOTED_REGEX = "(?i)[a-z][\\w]*";
public static final Pattern UNQUOTED = Pattern.compile(UNQUOTED_REGEX);
public static final String QUOTED_REGEX = "(?i)[a-z]([\\w]*(\"\")+[\\w]*)+";
public static final Pattern QUOTED = Pattern.compile(QUOTED_REGEX);
private String identifier;
private String unquoted;
private boolean quoted;
/**
* Create a new {@link CqlIdentifier} without force-quoting it. It may end up quoted, depending on its value.
*
* @see #cqlId(CharSequence)
*/
public CqlIdentifier(CharSequence identifier) {
this(identifier, false);
}
/**
* Create a new CQL identifier, optionally force-quoting it. Force-quoting can be used to preserve identifier case.
* <ul>
* <li>If the given identifier is a legal quoted identifier or <code>forceQuote</code> is <code>true</code>,
* {@link #isQuoted()} will return <code>true</code> and the identifier will be quoted when rendered.</li>
* <li>If the given identifier is a legal unquoted identifier, {@link #isQuoted()} will return <code>false</code>,
* plus the name will be converted to lower case and rendered as such.</li>
* <li>If the given identifier is illegal, an {@link IllegalArgumentException} is thrown.</li>
* </ul>
*
* @see #cqlId(CharSequence, boolean)
* @see #quotedCqlId(CharSequence)
*/
public CqlIdentifier(CharSequence identifier, boolean forceQuote) {
setIdentifier(identifier, forceQuote);
}
/**
* Factory method for {@link CqlIdentifier}. Convenient if imported statically.
*
@@ -90,36 +124,6 @@ public final class CqlIdentifier implements Comparable<CqlIdentifier>, Serializa
return QUOTED.matcher(chars).matches() || ReservedKeyword.isReserved(chars);
}
private String identifier;
private String unquoted;
private boolean quoted;
/**
* Creates a new {@link CqlIdentifier} without force-quoting it. It may end up quoted, depending on its value.
*
* @see #cqlId(CharSequence)
*/
public CqlIdentifier(CharSequence identifier) {
this(identifier, false);
}
/**
* Creates a new CQL identifier, optionally force-quoting it. Force-quoting can be used to preserve identifier case.
* <ul>
* <li>If the given identifier is a legal quoted identifier or <code>forceQuote</code> is <code>true</code>,
* {@link #isQuoted()} will return <code>true</code> and the identifier will be quoted when rendered.</li>
* <li>If the given identifier is a legal unquoted identifier, {@link #isQuoted()} will return <code>false</code>,
* plus the name will be converted to lower case and rendered as such.</li>
* <li>If the given identifier is illegal, an {@link IllegalArgumentException} is thrown.</li>
* </ul>
*
* @see #cqlId(CharSequence, boolean)
* @see #quotedCqlId(CharSequence)
*/
public CqlIdentifier(CharSequence identifier, boolean forceQuote) {
setIdentifier(identifier, forceQuote);
}
/**
* Tests & sets the given identifier.
*/
@@ -138,8 +142,8 @@ public final class CqlIdentifier implements Comparable<CqlIdentifier>, Serializa
} else if (isUnquotedIdentifier(string)) {
this.identifier = this.unquoted = string.toLowerCase();
} else {
throw new IllegalArgumentException(String.format(
"given string [%s] is not a valid quoted or unquoted identifier", identifier));
throw new IllegalArgumentException(
String.format("given string [%s] is not a valid quoted or unquoted identifier", identifier));
}
}
@@ -194,27 +198,33 @@ public final class CqlIdentifier implements Comparable<CqlIdentifier>, Serializa
* Compares this {@link CqlIdentifier} to the given object. Note that if a {@link CharSequence} is given, a new
* {@link CqlIdentifier} is created from it and compared, such that a {@link CharSequence} can be effectively equal to
* a {@link CqlIdentifier}.
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
public boolean equals(Object o) {
if (this == obj) {
if (this == o)
return true;
}
if (!(obj instanceof CqlIdentifier || obj instanceof CharSequence)) {
if (!(o instanceof CqlIdentifier))
return false;
}
CqlIdentifier that = (obj instanceof CqlIdentifier) ? (CqlIdentifier) obj : cqlId((CharSequence) obj);
CqlIdentifier that = (CqlIdentifier) o;
return (this.quoted == that.quoted && this.identifier.equals(that.identifier));
if (quoted != that.quoted)
return false;
return identifier != null ? identifier.equals(that.identifier) : that.identifier == null;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
// TODO hmmm, re-evaluate this since it is not a proper hash code matching equals!
public int hashCode() {
return ((Boolean) quoted).hashCode() ^ identifier.hashCode();
int result = identifier != null ? identifier.hashCode() : 0;
result = 31 * result + (quoted ? 1 : 0);
return result;
}
/**

View File

@@ -54,7 +54,7 @@ public final class KeyspaceIdentifier implements Comparable<KeyspaceIdentifier>
private String identifier;
/**
* Creates a new {@link KeyspaceIdentifier}.
* Create a new {@link KeyspaceIdentifier}.
*/
public KeyspaceIdentifier(CharSequence identifier) {
setIdentifier(identifier);
@@ -130,6 +130,9 @@ public final class KeyspaceIdentifier implements Comparable<KeyspaceIdentifier>
return this.identifier.equals(other.identifier);
}
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(KeyspaceIdentifier that) {
return this.identifier.compareTo(that.identifier);

View File

@@ -49,7 +49,7 @@ public class AlterTableCqlGenerator extends TableOptionsCqlGenerator<AlterTableS
}
/**
* Creates a new {@literal {@link AlterTableCqlGenerator}.
* Create a new {@literal {@link AlterTableCqlGenerator}.
*
* @param specification must not be {@literal null}.
*/

View File

@@ -15,7 +15,7 @@
*/
package org.springframework.cassandra.core.cql.generator;
import static org.springframework.cassandra.core.cql.CqlStringUtils.noNull;
import static org.springframework.cassandra.core.cql.CqlStringUtils.*;
import org.springframework.cassandra.core.keyspace.AddColumnSpecification;
import org.springframework.cassandra.core.keyspace.AlterColumnSpecification;
@@ -42,7 +42,7 @@ public class AlterUserTypeCqlGenerator extends UserTypeNameCqlGenerator<AlterUse
}
/**
* Creates a new {@link AlterUserTypeCqlGenerator} for a {@link AlterUserTypeSpecification}.
* Create a new {@link AlterUserTypeCqlGenerator} for a {@link AlterUserTypeSpecification}.
*
* @param specification must not be {@literal null}.
*/

View File

@@ -15,7 +15,7 @@
*/
package org.springframework.cassandra.core.cql.generator;
import static org.springframework.cassandra.core.cql.CqlStringUtils.noNull;
import static org.springframework.cassandra.core.cql.CqlStringUtils.*;
import org.springframework.cassandra.core.keyspace.CreateUserTypeSpecification;
import org.springframework.cassandra.core.keyspace.FieldSpecification;
@@ -36,7 +36,7 @@ public class CreateUserTypeCqlGenerator extends UserTypeNameCqlGenerator<CreateU
}
/**
* Creates a new {@link CreateUserTypeCqlGenerator} for a given {@link CreateUserTypeSpecification}.
* Create a new {@link CreateUserTypeCqlGenerator} for a given {@link CreateUserTypeSpecification}.
*
* @param specification must not be {@literal null}.
*/

View File

@@ -15,7 +15,7 @@
*/
package org.springframework.cassandra.core.cql.generator;
import static org.springframework.cassandra.core.cql.CqlStringUtils.noNull;
import static org.springframework.cassandra.core.cql.CqlStringUtils.*;
import org.springframework.cassandra.core.keyspace.DropUserTypeSpecification;
@@ -34,7 +34,7 @@ public class DropUserTypeCqlGenerator extends UserTypeNameCqlGenerator<DropUserT
}
/**
* Creates a new {@link DropUserTypeCqlGenerator} for a given {@link DropUserTypeSpecification}.
* Create a new {@link DropUserTypeCqlGenerator} for a given {@link DropUserTypeSpecification}.
*
* @param specification must not be {@literal null}.
*/

View File

@@ -34,8 +34,8 @@ public abstract class UserTypeNameCqlGenerator<T extends UserTypeNameSpecificati
private UserTypeNameSpecification<T> specification;
/**
* Creates a new {@link UserTypeNameCqlGenerator}.
*
* Create a new {@link UserTypeNameCqlGenerator}.
*
* @param specification must not be {@literal null}.
*/
public UserTypeNameCqlGenerator(UserTypeNameSpecification<T> specification) {
@@ -44,7 +44,7 @@ public abstract class UserTypeNameCqlGenerator<T extends UserTypeNameSpecificati
/**
* Sets the {@link UserTypeNameSpecification}.
*
*
* @param specification must not be {@literal null}.
*/
protected final void setSpecification(UserTypeNameSpecification<T> specification) {

View File

@@ -29,7 +29,7 @@ import com.datastax.driver.core.DataType;
public class AddColumnSpecification extends ColumnTypeChangeSpecification {
/**
* Creates a new {@link AddColumnSpecification} for the given {@code name} and {@link type}
* Create a new {@link AddColumnSpecification} for the given {@code name} and {@link type}
*
* @param name must not be empty or {@literal null}.
* @param type must not be {@literal null}.
@@ -39,7 +39,7 @@ public class AddColumnSpecification extends ColumnTypeChangeSpecification {
}
/**
* Creates a new {@link AddColumnSpecification} for the given {@code name} and {@link type}
* Create a new {@link AddColumnSpecification} for the given {@code name} and {@link type}
*
* @param name must not be {@literal null}.
* @param type must not be {@literal null}.

View File

@@ -1,12 +1,12 @@
/*
* Copyright 2013-2014 the original author or authors.
*
*
* Licensed 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.
@@ -44,4 +44,5 @@ public class AlterKeyspaceSpecification extends KeyspaceOptionsSpecification<Alt
public AlterKeyspaceSpecification(KeyspaceIdentifier name) {
name(name);
}
}

View File

@@ -1,12 +1,12 @@
/*
* Copyright 2013-2016 the original author or authors.
*
*
* Licensed 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.
@@ -22,7 +22,7 @@ import org.springframework.util.Assert;
/**
* Base value object class for column change specifications.
*
*
* @author Matthew T. Adams
* @author Mark Paluch
*/
@@ -31,8 +31,8 @@ public abstract class ColumnChangeSpecification {
protected CqlIdentifier name;
/**
* Creates a new {@link ColumnChangeSpecification}.
*
* Create a new {@link ColumnChangeSpecification}.
*
* @param name must not be empty or {@literal null}.
*/
protected ColumnChangeSpecification(String name) {
@@ -40,8 +40,8 @@ public abstract class ColumnChangeSpecification {
}
/**
* Creates a new {@link ColumnChangeSpecification}.
*
* Create a new {@link ColumnChangeSpecification}.
*
* @param name must not be {@literal null}.
*/
protected ColumnChangeSpecification(CqlIdentifier name) {
@@ -50,7 +50,7 @@ public abstract class ColumnChangeSpecification {
/**
* Sets the column name.
*
*
* @param name must not be {@literal null}.
*/
protected void setName(CqlIdentifier name) {

View File

@@ -46,8 +46,11 @@ public class ColumnSpecification {
public static final Ordering DEFAULT_ORDERING = ASCENDING;
private CqlIdentifier name;
private DataType type; // TODO: determining if we should be coupling this to Datastax Java Driver type?
private PrimaryKeyType keyType;
private Ordering ordering;
/**
@@ -173,9 +176,12 @@ public class ColumnSpecification {
}
public StringBuilder toCql(StringBuilder cql) {
return (cql = noNull(cql)).append(name).append(" ").append(type);
return noNull(cql).append(name).append(" ").append(type);
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return toCql(null).append(" /* keyType=").append(keyType).append(", ordering=").append(ordering).append(" */ ")

View File

@@ -33,7 +33,7 @@ public abstract class ColumnTypeChangeSpecification extends ColumnChangeSpecific
private final DataType type;
/**
* Creates a new {@link ColumnTypeChangeSpecification} for the given {@code name} and {@link type}
* Create a new {@link ColumnTypeChangeSpecification} for the given {@code name} and {@link type}
*
* @param name must not be empty or {@literal null}.
* @param type must not be {@literal null}.
@@ -43,7 +43,7 @@ public abstract class ColumnTypeChangeSpecification extends ColumnChangeSpecific
}
/**
* Creates a new {@link ColumnTypeChangeSpecification} for the given {@code name} and {@link type}
* Create a new {@link ColumnTypeChangeSpecification} for the given {@code name} and {@link type}
*
* @param name must not be {@literal null}.
* @param type must not be {@literal null}.

View File

@@ -30,6 +30,12 @@ import org.springframework.util.StringUtils;
public class CreateIndexSpecification extends IndexNameSpecification<CreateIndexSpecification>
implements IndexDescriptor {
private boolean ifNotExists = false;
private boolean custom = false;
private CqlIdentifier tableName;
private CqlIdentifier columnName;
private String using;
/**
* Entry point into the {@link CreateIndexSpecification}'s fluent API to create a index. Convenient if imported
* statically.
@@ -54,12 +60,6 @@ public class CreateIndexSpecification extends IndexNameSpecification<CreateIndex
return new CreateIndexSpecification().name(name);
}
private boolean ifNotExists = false;
private boolean custom = false;
private CqlIdentifier tableName;
private CqlIdentifier columnName;
private String using;
/**
* Causes the inclusion of an <code>IF NOT EXISTS</code> clause.
*
@@ -83,6 +83,9 @@ public class CreateIndexSpecification extends IndexNameSpecification<CreateIndex
return ifNotExists;
}
/* (non-Javadoc)
* @see org.springframework.cassandra.core.keyspace.IndexDescriptor#isCustom()
*/
@Override
public boolean isCustom() {
return custom;
@@ -101,11 +104,17 @@ public class CreateIndexSpecification extends IndexNameSpecification<CreateIndex
return this;
}
/* (non-Javadoc)
* @see org.springframework.cassandra.core.keyspace.IndexDescriptor#getUsing()
*/
@Override
public String getUsing() {
return using;
}
/* (non-Javadoc)
* @see org.springframework.cassandra.core.keyspace.IndexDescriptor#getColumnName()
*/
@Override
public CqlIdentifier getColumnName() {
return columnName;
@@ -128,6 +137,9 @@ public class CreateIndexSpecification extends IndexNameSpecification<CreateIndex
return this;
}
/* (non-Javadoc)
* @see org.springframework.cassandra.core.keyspace.IndexDescriptor#getTableName()
*/
@Override
public CqlIdentifier getTableName() {
return tableName;

View File

@@ -28,18 +28,25 @@ import org.springframework.util.Assert;
* A default implementation of {@link Option}.
*
* @author Matthew T. Adams
* @author Mark Paluch
*/
public class DefaultOption implements Option {
private String name;
private Class<?> type;
private boolean requiresValue;
private boolean escapesValue;
private boolean quotesValue;
public DefaultOption(String name, Class<?> type, boolean requiresValue, boolean escapesValue, boolean quotesValue) {
setName(name);
setType(type);
this.requiresValue = requiresValue;
this.escapesValue = escapesValue;
this.quotesValue = quotesValue;
@@ -100,30 +107,51 @@ public class DefaultOption implements Option {
return false;
}
/* (non-Javadoc)
* @see org.springframework.cassandra.core.keyspace.Option#getType()
*/
public Class<?> getType() {
return type;
}
/* (non-Javadoc)
* @see org.springframework.cassandra.core.keyspace.Option#getName()
*/
public String getName() {
return name;
}
/* (non-Javadoc)
* @see org.springframework.cassandra.core.keyspace.Option#takesValue()
*/
public boolean takesValue() {
return type != null;
}
/* (non-Javadoc)
* @see org.springframework.cassandra.core.keyspace.Option#requiresValue()
*/
public boolean requiresValue() {
return this.requiresValue;
}
/* (non-Javadoc)
* @see org.springframework.cassandra.core.keyspace.Option#escapesValue()
*/
public boolean escapesValue() {
return this.escapesValue;
}
/* (non-Javadoc)
* @see org.springframework.cassandra.core.keyspace.Option#quotesValue()
*/
public boolean quotesValue() {
return this.quotesValue;
}
/* (non-Javadoc)
* @see org.springframework.cassandra.core.keyspace.Option#checkValue(java.lang.Object)
*/
public void checkValue(Object value) {
if (takesValue()) {
if (value == null) {
@@ -158,6 +186,9 @@ public class DefaultOption implements Option {
return string;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "[name=" + name + ", type=" + type.getName() + ", requiresValue=" + requiresValue + ", escapesValue="

View File

@@ -62,28 +62,33 @@ public abstract class KeyspaceActionSpecification<T extends KeyspaceActionSpecif
}
/**
* Determine the KeyspaceActionSpecifications are the same if they have the same "name" and same class.
* Equality incorporates the exact type to distinguish between instances based on this type.
*
* @param that The object to compare this to.
* @return Are this and that the same?
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object that) {
if (this == that) {
public boolean equals(Object o) {
if (this == o)
return true;
}
if (that == null) {
if (!(o instanceof KeyspaceActionSpecification) || !getClass().equals(o.getClass()))
return false;
}
if (!(that instanceof KeyspaceActionSpecification)) {
return false;
}
KeyspaceActionSpecification<?> other = (KeyspaceActionSpecification<?>) that;
return this.name.equals(other.name) && this.getClass().equals(that.getClass());
KeyspaceActionSpecification<?> that = (KeyspaceActionSpecification<?>) o;
return name != null ? name.equals(that.name) : that.name == null;
}
/**
* Hash code incorporates the exact type to distinguish between instances based on this type.
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return name.hashCode() ^ getClass().hashCode();
int result = name != null ? name.hashCode() : 0;
result = 31 * result + (getClass().hashCode());
return result;
}
}

View File

@@ -32,7 +32,7 @@ public class RenameColumnSpecification extends ColumnChangeSpecification {
private final CqlIdentifier targetName;
/**
* Creates a new {@link ColumnChangeSpecification}.
* Create a new {@link ColumnChangeSpecification}.
*
* @param from must not be empty or {@literal null}.
* @param to must not be empty or {@literal null}.
@@ -42,7 +42,7 @@ public class RenameColumnSpecification extends ColumnChangeSpecification {
}
/**
* Creates a new {@link ColumnChangeSpecification}.
* Create a new {@link ColumnChangeSpecification}.
*
* @param from must not be {@literal null}.
* @param to must not be {@literal null}.

View File

@@ -55,7 +55,7 @@ public abstract class AbstractKeyspaceCreatingIntegrationTest extends AbstractEm
protected final String keyspace;
/**
* Creates a new {@link AbstractKeyspaceCreatingIntegrationTest}.
* Create a new {@link AbstractKeyspaceCreatingIntegrationTest}.
*/
public AbstractKeyspaceCreatingIntegrationTest() {
this(keyspaceRule.getKeyspaceName());

View File

@@ -58,20 +58,27 @@ public class CassandraRule extends ExternalResource {
private static ResourceHolder resourceHolder;
private final CassandraConnectionProperties properties = new CassandraConnectionProperties();
private final String configurationFileName;
private final long startUpTimeout;
private List<SessionCallback<Void>> before = new ArrayList<SessionCallback<Void>>();
private Map<SessionCallback<?>, InvocationMode> invocationModeMap = new HashMap<SessionCallback<?>, InvocationMode>();
private List<SessionCallback<Void>> after = new ArrayList<SessionCallback<Void>>();
private Session session;
private Cluster cluster;
private CassandraRule parent;
private Integer cassandraPort;
/**
* Creates a new {@link CassandraRule} and allows the use of a config file.
* Create a new {@link CassandraRule} and allows the use of a config file.
*
* @param yamlConfigurationResource name of the configuration resource, must not be {@literal null} and not empty
*/
@@ -80,7 +87,7 @@ public class CassandraRule extends ExternalResource {
}
/**
* Creates a new {@link CassandraRule}, allows the use of a config file and to provide a startup timeout.
* Create a new {@link CassandraRule}, allows the use of a config file and to provide a startup timeout.
*
* @param yamlConfigurationResource name of the configuration resource, must not be {@literal null} and not empty
* @param startUpTimeout the startup timeout
@@ -94,7 +101,7 @@ public class CassandraRule extends ExternalResource {
}
/**
* Creates a new {@link CassandraRule} using a parent {@link CassandraRule} to preserve cluster/connection facilities.
* Create a new {@link CassandraRule} using a parent {@link CassandraRule} to preserve cluster/connection facilities.
*
* @param parent the parent instance
*/

View File

@@ -32,15 +32,15 @@ public abstract class CallbackSynchronizationSupport {
private final CountDownLatch latch;
/**
* Creates a new {@link CallbackSynchronizationSupport}
* Create a new {@link CallbackSynchronizationSupport}
*/
protected CallbackSynchronizationSupport() {
this(1);
}
/**
* Creates a new {@link CallbackSynchronizationSupport} for a given {@code latchCount} of callbacks.
*
* Create a new {@link CallbackSynchronizationSupport} for a given {@code latchCount} of callbacks.
*
* @param latchCount {@link CallbackSynchronizationSupport} for a given {@code latchCount} of callbacks
*/
protected CallbackSynchronizationSupport(int latchCount) {
@@ -49,7 +49,7 @@ public abstract class CallbackSynchronizationSupport {
/**
* Await results without a timeout.
*
*
* @throws InterruptedException
*/
public final void await() throws InterruptedException {
@@ -58,7 +58,7 @@ public abstract class CallbackSynchronizationSupport {
/**
* Await the results with a timeout.
*
*
* @param timeout must be greater or equal to 0
* @param timeUnit must not be {@literal null}.
* @throws InterruptedException

View File

@@ -33,7 +33,7 @@ public class CassandraConnectionProperties extends Properties {
protected String resourceName = null;
/**
* Creates a new {@link CassandraConnectionProperties} using properties from
* Create a new {@link CassandraConnectionProperties} using properties from
* {@code config/cassandra-connection.properties}.
*/
public CassandraConnectionProperties() {

View File

@@ -34,9 +34,11 @@ import com.google.common.io.Resources;
public class CqlDataSet {
private URL location = null;
private String keyspaceName = null;
private CqlDataSet(URL location, String keyspaceName) {
this.location = location;
this.keyspaceName = keyspaceName;
}
@@ -65,7 +67,7 @@ public class CqlDataSet {
}
/**
* Bind the {@link CqlDataSet} to a particular keyspace. Creates a new instance of the {@link CqlDataSet} with the
* Bind the {@link CqlDataSet} to a particular keyspace. Create a new instance of the {@link CqlDataSet} with the
* keyspace name set.
*
* @param keyspaceName

View File

@@ -38,7 +38,7 @@ public abstract class AbstractCassandraConverter implements CassandraConverter,
protected EntityInstantiators instantiators = new EntityInstantiators();
/**
* Creates a new {@link AbstractCassandraConverter} using the given {@link ConversionService}.
* Create a new {@link AbstractCassandraConverter} using the given {@link ConversionService}.
*/
public AbstractCassandraConverter(ConversionService conversionService) {
this.conversionService = conversionService == null ? new DefaultConversionService() : conversionService;

View File

@@ -33,10 +33,11 @@ import com.datastax.driver.core.Row;
public class BasicCassandraRowValueProvider implements CassandraRowValueProvider {
private final ColumnReader reader;
private final SpELExpressionEvaluator evaluator;
/**
* Creates a new {@link BasicCassandraRowValueProvider} with the given {@link Row} and
* Create a new {@link BasicCassandraRowValueProvider} with the given {@link Row} and
* {@link DefaultSpELExpressionEvaluator}.
*
* @param source must not be {@literal null}.

View File

@@ -33,11 +33,13 @@ import com.datastax.driver.core.UDTValue;
public class CassandraUDTValueProvider implements CassandraValueProvider {
private final UDTValue udtValue;
private final CodecRegistry codecRegistry;
private final SpELExpressionEvaluator evaluator;
/**
* Creates a new {@link CassandraUDTValueProvider} with the given {@link UDTValue} and
* Create a new {@link CassandraUDTValueProvider} with the given {@link UDTValue} and
* {@link DefaultSpELExpressionEvaluator}.
*
* @param udtValue must not be {@literal null}.

View File

@@ -28,11 +28,13 @@ import org.springframework.util.Assert;
class ConverterRegistration {
private final ConvertiblePair convertiblePair;
private final boolean reading;
private final boolean writing;
/**
* Creates a new {@link ConverterRegistration}.
* Create a new {@link ConverterRegistration}.
*
* @param convertiblePair must not be {@literal null}.
* @param isReading whether to force to consider the converter for reading.
@@ -48,7 +50,7 @@ class ConverterRegistration {
}
/**
* Creates a new {@link ConverterRegistration} from the given source and target type and read/write flags.
* Create a new {@link ConverterRegistration} from the given source and target type and read/write flags.
*
* @param source the source type to be converted from, must not be {@literal null}.
* @param target the target type to be converted to, must not be {@literal null}.

View File

@@ -77,7 +77,7 @@ public class CustomConversions {
}
/**
* Creates a new {@link CustomConversions} instance registering the given converters.
* Create a new {@link CustomConversions} instance registering the given converters.
*
* @param converters
*/

View File

@@ -22,19 +22,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import com.datastax.driver.core.CodecRegistry;
import com.datastax.driver.core.DataType;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.TypeCodec;
import com.datastax.driver.core.UDTValue;
import com.datastax.driver.core.UserType;
import com.datastax.driver.core.querybuilder.Clause;
import com.datastax.driver.core.querybuilder.Delete;
import com.datastax.driver.core.querybuilder.Insert;
import com.datastax.driver.core.querybuilder.QueryBuilder;
import com.datastax.driver.core.querybuilder.Select;
import com.datastax.driver.core.querybuilder.Update;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
@@ -66,6 +53,19 @@ import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
import com.datastax.driver.core.CodecRegistry;
import com.datastax.driver.core.DataType;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.TypeCodec;
import com.datastax.driver.core.UDTValue;
import com.datastax.driver.core.UserType;
import com.datastax.driver.core.querybuilder.Clause;
import com.datastax.driver.core.querybuilder.Delete;
import com.datastax.driver.core.querybuilder.Insert;
import com.datastax.driver.core.querybuilder.QueryBuilder;
import com.datastax.driver.core.querybuilder.Select;
import com.datastax.driver.core.querybuilder.Update;
/**
* {@link CassandraConverter} that uses a {@link MappingContext} to do sophisticated mapping of domain objects to
* {@link Row}.
@@ -94,14 +94,14 @@ public class MappingCassandraConverter extends AbstractCassandraConverter
private final Logger log = LoggerFactory.getLogger(getClass());
/**
* Creates a new {@link MappingCassandraConverter} with a {@link BasicCassandraMappingContext}.
* Create a new {@link MappingCassandraConverter} with a {@link BasicCassandraMappingContext}.
*/
public MappingCassandraConverter() {
this(new BasicCassandraMappingContext());
}
/**
* Creates a new {@link MappingCassandraConverter} with the given {@link CassandraMappingContext}.
* Create a new {@link MappingCassandraConverter} with the given {@link CassandraMappingContext}.
*
* @param mappingContext must not be {@literal null}.
*/
@@ -598,7 +598,7 @@ public class MappingCassandraConverter extends AbstractCassandraConverter
}
/**
* Creates a new {@link ConvertingPropertyAccessor} for the given source and entity.
* Create a new {@link ConvertingPropertyAccessor} for the given source and entity.
*
* @param source must not be {@literal null}.
* @param entity must not be {@literal null}.

View File

@@ -33,10 +33,10 @@ import com.datastax.driver.core.querybuilder.QueryBuilder;
*/
class CassandraBatchTemplate implements CassandraBatchOperations {
static final Object[] EMPTY_ARRAY = new Object[0];
private AtomicBoolean executed = new AtomicBoolean();
private final Batch batch;
private final CassandraOperations operations;
/* (non-Javadoc) */
@@ -51,7 +51,7 @@ class CassandraBatchTemplate implements CassandraBatchOperations {
}
/**
* Creates a new {@link CassandraBatchTemplate} given {@link CassandraOperations}.
* Create a new {@link CassandraBatchTemplate} given {@link CassandraOperations}.
*
* @param operations must not be {@literal null}.
*/

View File

@@ -27,12 +27,21 @@ import com.datastax.driver.core.Row;
*
* @author Alex Shvid
* @author Matthew T. Adams
* @author Mark Paluch
*/
public class CassandraConverterRowCallback<T> implements RowCallback<T> {
private final CassandraConverter reader;
private final Class<T> type;
/**
* Create a new {@link CassandraConverterRowCallback} instance given {@link CassandraConverter} and a target
* {@link Class type}.
*
* @param reader must not be {@literal null}.
* @param type must not be {@literal null}.
*/
public CassandraConverterRowCallback(CassandraConverter reader, Class<T> type) {
Assert.notNull(reader, "CassandraConverter must not be null");
@@ -42,6 +51,9 @@ public class CassandraConverterRowCallback<T> implements RowCallback<T> {
this.type = type;
}
/* (non-Javadoc)
* @see org.springframework.cassandra.core.RowCallback#doWith(com.datastax.driver.core.Row)
*/
@Override
public T doWith(Row row) {
return reader.read(type, row);

View File

@@ -49,10 +49,11 @@ import org.springframework.util.Assert;
public class CassandraPersistentEntitySchemaCreator {
private final CassandraAdminOperations cassandraAdminOperations;
private final CassandraMappingContext mappingContext;
/**
* Creates a new {@link CassandraPersistentEntitySchemaCreator} for the given {@link CassandraMappingContext} and
* Create a new {@link CassandraPersistentEntitySchemaCreator} for the given {@link CassandraMappingContext} and
* {@link CassandraAdminOperations}.
*
* @param mappingContext must not be {@literal null}.

View File

@@ -36,10 +36,11 @@ import org.springframework.util.Assert;
public class CassandraPersistentEntitySchemaDropper {
private final CassandraAdminOperations cassandraAdminOperations;
private final CassandraMappingContext mappingContext;
/**
* Creates a new {@link CassandraPersistentEntitySchemaDropper} for the given {@link CassandraMappingContext} and
* Create a new {@link CassandraPersistentEntitySchemaDropper} for the given {@link CassandraMappingContext} and
* {@link CassandraAdminOperations}.
*
* @param mappingContext must not be {@literal null}.

View File

@@ -15,9 +15,9 @@
*/
package org.springframework.data.cassandra.mapping;
import static org.springframework.cassandra.core.cql.CqlIdentifier.cqlId;
import static org.springframework.cassandra.core.keyspace.CreateTableSpecification.createTable;
import static org.springframework.data.cassandra.mapping.CassandraSimpleTypeHolder.getDataTypeFor;
import static org.springframework.cassandra.core.cql.CqlIdentifier.*;
import static org.springframework.cassandra.core.keyspace.CreateTableSpecification.*;
import static org.springframework.data.cassandra.mapping.CassandraSimpleTypeHolder.*;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
@@ -30,10 +30,6 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import com.datastax.driver.core.DataType;
import com.datastax.driver.core.TableMetadata;
import com.datastax.driver.core.UserType;
import org.springframework.beans.BeansException;
import org.springframework.cassandra.core.cql.CqlIdentifier;
import org.springframework.cassandra.core.keyspace.CreateTableSpecification;
@@ -52,6 +48,10 @@ import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import com.datastax.driver.core.DataType;
import com.datastax.driver.core.TableMetadata;
import com.datastax.driver.core.UserType;
/**
* Default implementation of a {@link MappingContext} for Cassandra using {@link CassandraPersistentEntity} and
* {@link CassandraPersistentProperty} as primary abstractions.
@@ -87,7 +87,7 @@ public class BasicCassandraMappingContext
private UserTypeResolver userTypeResolver;
/**
* Creates a new {@link BasicCassandraMappingContext}.
* Create a new {@link BasicCassandraMappingContext}.
*/
public BasicCassandraMappingContext() {
setCustomConversions(new CustomConversions(Collections.EMPTY_LIST));

View File

@@ -65,12 +65,17 @@ public class BasicCassandraPersistentEntity<T> extends BasicPersistentEntity<T,
protected StandardEvaluationContext spelContext;
/**
* Create a new {@link BasicCassandraPersistentEntity} given {@link TypeInformation}.
*
* @param typeInformation must not be {@literal null}.
*/
public BasicCassandraPersistentEntity(TypeInformation<T> typeInformation) {
this(typeInformation, null, DEFAULT_VERIFIER);
}
/**
* Creates a new {@link BasicCassandraPersistentEntity} with the given {@link TypeInformation}. Will default the table
* Create a new {@link BasicCassandraPersistentEntity} with the given {@link TypeInformation}. Will default the table
* name to the entity's simple type name.
*
* @param typeInformation
@@ -80,7 +85,7 @@ public class BasicCassandraPersistentEntity<T> extends BasicPersistentEntity<T,
}
/**
* Creates a new {@link BasicCassandraPersistentEntity} with the given {@link TypeInformation}. Will default the table
* Create a new {@link BasicCassandraPersistentEntity} with the given {@link TypeInformation}. Will default the table
* name to the entity's simple type name.
*
* @param typeInformation
@@ -103,21 +108,33 @@ public class BasicCassandraPersistentEntity<T> extends BasicPersistentEntity<T,
: determineDefaultName());
}
/* (non-Javadoc)
* @see org.springframework.data.mapping.model.BasicPersistentEntity#addAssociation(org.springframework.data.mapping.Association)
*/
@Override
public void addAssociation(Association<CassandraPersistentProperty> association) {
throw new UnsupportedCassandraOperationException("Cassandra does not support associations");
}
/* (non-Javadoc)
* @see org.springframework.data.mapping.model.BasicPersistentEntity#doWithAssociations(org.springframework.data.mapping.AssociationHandler)
*/
@Override
public void doWithAssociations(AssociationHandler<CassandraPersistentProperty> handler) {
throw new UnsupportedCassandraOperationException("Cassandra does not support associations");
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentEntity#isCompositePrimaryKey()
*/
@Override
public boolean isCompositePrimaryKey() {
return (findAnnotation(PrimaryKeyClass.class) != null);
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentEntity#getCompositePrimaryKeyProperties()
*/
@Override
public List<CassandraPersistentProperty> getCompositePrimaryKeyProperties() {
@@ -147,6 +164,9 @@ public class BasicCassandraPersistentEntity<T> extends BasicPersistentEntity<T,
});
}
/* (non-Javadoc)
* @see org.springframework.data.mapping.model.BasicPersistentEntity#verify()
*/
@Override
public void verify() throws MappingException {
super.verify();
@@ -156,6 +176,9 @@ public class BasicCassandraPersistentEntity<T> extends BasicPersistentEntity<T,
}
}
/* (non-Javadoc)
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
*/
@Override
public void setApplicationContext(ApplicationContext context) throws BeansException {
@@ -168,11 +191,17 @@ public class BasicCassandraPersistentEntity<T> extends BasicPersistentEntity<T,
spelContext.setRootObject(context);
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentEntity#getApplicationContext()
*/
@Override
public ApplicationContext getApplicationContext() {
return context;
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentEntity#setForceQuote(boolean)
*/
@Override
public void setForceQuote(boolean forceQuote) {
if (this.forceQuote == null || this.forceQuote != forceQuote) {
@@ -181,11 +210,17 @@ public class BasicCassandraPersistentEntity<T> extends BasicPersistentEntity<T,
}
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentEntity#getMappingContext()
*/
@Override
public CassandraMappingContext getMappingContext() {
return mappingContext;
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentEntity#setTableName(org.springframework.cassandra.core.cql.CqlIdentifier)
*/
@Override
public void setTableName(CqlIdentifier tableName) {
@@ -193,6 +228,9 @@ public class BasicCassandraPersistentEntity<T> extends BasicPersistentEntity<T,
this.tableName = tableName;
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentEntity#getTableName()
*/
@Override
public CqlIdentifier getTableName() {
tableName = (tableName != null ? tableName : determineTableName());
@@ -207,7 +245,7 @@ public class BasicCassandraPersistentEntity<T> extends BasicPersistentEntity<T,
}
/**
* @return Returns the verifier.
* @return the verifier.
*/
public CassandraPersistentEntityMetadataVerifier getVerifier() {
return verifier;

View File

@@ -84,7 +84,7 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
private final UserTypeResolver userTypeResolver;
/**
* Creates a new {@link BasicCassandraPersistentProperty}.
* Create a new {@link BasicCassandraPersistentProperty}.
*
* @param field the actual {@link Field} in the domain entity corresponding to this persistent entity.
* @param propertyDescriptor a {@link PropertyDescriptor} for the corresponding property in the domain entity.
@@ -98,7 +98,7 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
}
/**
* Creates a new {@link BasicCassandraPersistentProperty}.
* Create a new {@link BasicCassandraPersistentProperty}.
*
* @param field the actual {@link Field} in the domain entity corresponding to this persistent entity.
* @param propertyDescriptor a {@link PropertyDescriptor} for the corresponding property in the domain entity.
@@ -119,6 +119,9 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
}
}
/* (non-Javadoc)
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
*/
@Override
public void setApplicationContext(ApplicationContext context) {
@@ -131,25 +134,40 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
spelContext.setRootObject(context);
}
/* (non-Javadoc)
* @see org.springframework.data.mapping.model.AbstractPersistentProperty#getOwner()
*/
@Override
public CassandraPersistentEntity<?> getOwner() {
return (CassandraPersistentEntity<?>) super.getOwner();
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentProperty#isCompositePrimaryKey()
*/
@Override
public boolean isCompositePrimaryKey() {
return (AnnotatedElementUtils.findMergedAnnotation(getType(), PrimaryKeyClass.class) != null);
}
/**
* @return
*/
public Class<?> getCompositePrimaryKeyType() {
return (isCompositePrimaryKey() ? getType() : null);
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentProperty#getCompositePrimaryKeyTypeInformation()
*/
@Override
public TypeInformation<?> getCompositePrimaryKeyTypeInformation() {
return (isCompositePrimaryKey() ? ClassTypeInformation.from(getCompositePrimaryKeyType()) : null);
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentProperty#getColumnName()
*/
@Override
public CqlIdentifier getColumnName() {
@@ -160,6 +178,9 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
return columnNames.get(0);
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentProperty#getPrimaryKeyOrdering()
*/
@Override
public Ordering getPrimaryKeyOrdering() {
@@ -168,6 +189,9 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
return (primaryKeyColumn != null ? primaryKeyColumn.ordering() : null);
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentProperty#getDataType()
*/
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentProperty#getDataType()
*/
@@ -264,11 +288,17 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
return userType;
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentProperty#isIndexed()
*/
@Override
public boolean isIndexed() {
return isAnnotationPresent(Indexed.class);
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentProperty#isClusterKeyColumn()
*/
@Override
public boolean isClusterKeyColumn() {
@@ -277,6 +307,9 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
return (primaryKeyColumn != null && PrimaryKeyType.CLUSTERED.equals(primaryKeyColumn.type()));
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentProperty#isPartitionKeyColumn()
*/
@Override
public boolean isPartitionKeyColumn() {
@@ -285,6 +318,9 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
return (primaryKeyColumn != null && PrimaryKeyType.PARTITIONED.equals(primaryKeyColumn.type()));
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentProperty#isPrimaryKeyColumn()
*/
@Override
public boolean isPrimaryKeyColumn() {
return isAnnotationPresent(PrimaryKeyColumn.class);
@@ -330,6 +366,9 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
}
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentProperty#getColumnNames()
*/
@Override
public List<CqlIdentifier> getColumnNames() {
@@ -399,6 +438,9 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
});
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentProperty#setColumnName(org.springframework.cassandra.core.cql.CqlIdentifier)
*/
@Override
public void setColumnName(CqlIdentifier columnName) {
@@ -407,6 +449,9 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
setColumnNames(Collections.singletonList(columnName));
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentProperty#setColumnNames(java.util.List)
*/
@Override
public void setColumnNames(List<CqlIdentifier> columnNames) {
@@ -425,6 +470,9 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
.unmodifiableList(new ArrayList<CqlIdentifier>(columnNames));
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentProperty#setForceQuote(boolean)
*/
@Override
public void setForceQuote(boolean forceQuote) {
@@ -444,6 +492,9 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
setColumnNames(columnNames);
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentProperty#getCompositePrimaryKeyProperties()
*/
@Override
public List<CassandraPersistentProperty> getCompositePrimaryKeyProperties() {
@@ -453,6 +504,9 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
return getCompositePrimaryKeyEntity().getCompositePrimaryKeyProperties();
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentProperty#getCompositePrimaryKeyEntity()
*/
@Override
public CassandraPersistentEntity<?> getCompositePrimaryKeyEntity() {
@@ -463,16 +517,25 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
return mappingContext.getPersistentEntity(getCompositePrimaryKeyTypeInformation());
}
/* (non-Javadoc)
* @see org.springframework.data.mapping.model.AbstractPersistentProperty#getAssociation()
*/
@Override
public Association<CassandraPersistentProperty> getAssociation() {
throw new UnsupportedOperationException("Cassandra does not support associations");
}
/* (non-Javadoc)
* @see org.springframework.data.mapping.model.AbstractPersistentProperty#createAssociation()
*/
@Override
protected Association<CassandraPersistentProperty> createAssociation() {
return new Association<CassandraPersistentProperty>(this, null);
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.mapping.CassandraPersistentProperty#isMapLike()
*/
@Override
public boolean isMapLike() {
return ClassUtils.isAssignable(Map.class, getType());

View File

@@ -33,12 +33,13 @@ import com.datastax.driver.core.UserType;
public class CassandraUserTypePersistentEntity<T> extends BasicCassandraPersistentEntity<T> {
private final UserTypeResolver resolver;
private final Object lock = new Object();
private volatile UserType userType;
/**
* Creates a new {@link CassandraUserTypePersistentEntity}.
* Create a new {@link CassandraUserTypePersistentEntity}.
*
* @param typeInformation must not be {@literal null}.
* @param mappingContext must not be {@literal null}.

View File

@@ -34,7 +34,7 @@ public class CompositeCassandraPersistentEntityMetadataVerifier implements Cassa
private Collection<CassandraPersistentEntityMetadataVerifier> verifiers;
/**
* Creates a new {@link CompositeCassandraPersistentEntityMetadataVerifier} using default entity and primary key
* Create a new {@link CompositeCassandraPersistentEntityMetadataVerifier} using default entity and primary key
* verifiers.
*
* @see BasicCassandraPersistentEntityMetadataVerifier
@@ -46,7 +46,7 @@ public class CompositeCassandraPersistentEntityMetadataVerifier implements Cassa
}
/**
* Creates a new {@link CompositeCassandraPersistentEntityMetadataVerifier} for the given {@code verifiers}
* Create a new {@link CompositeCassandraPersistentEntityMetadataVerifier} for the given {@code verifiers}
*
* @param verifiers must not be {@literal null}.
*/

View File

@@ -99,8 +99,8 @@ public class EntityMapping {
this.tableName = tableName;
}
/**
* @inheritDoc
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
@@ -119,11 +119,12 @@ public class EntityMapping {
&& ObjectUtils.nullSafeEquals(this.getTableName(), that.getTableName());
}
/**
* @inheritDoc
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
int hashValue = 17;
hashValue = 37 * hashValue + ObjectUtils.nullSafeHashCode(this.getEntityClassName());
hashValue = 37 * hashValue + ObjectUtils.nullSafeHashCode(this.getForceQuote());
@@ -131,8 +132,8 @@ public class EntityMapping {
return hashValue;
}
/**
* @inheritDoc
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
@@ -141,7 +142,6 @@ public class EntityMapping {
getClass().getName(), getEntityClassName(), getTableName(), getForceQuote(), toString(getPropertyMappings()));
}
/* (non-Javadoc) */
private String toString(Map<?, ?> map) {
StringBuilder builder = new StringBuilder("[");
int count = 0;

View File

@@ -27,7 +27,9 @@ import org.springframework.util.ObjectUtils;
public class PropertyMapping {
private String columnName;
private String forceQuote;
private String propertyName;
public PropertyMapping(String propertyName) {
@@ -72,8 +74,8 @@ public class PropertyMapping {
this.propertyName = propertyName;
}
/**
* @inheritDoc
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
@@ -92,11 +94,12 @@ public class PropertyMapping {
&& ObjectUtils.nullSafeEquals(this.getForceQuote(), that.getForceQuote());
}
/**
* @inheritDoc
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
int hashValue = 17;
hashValue = 37 * hashValue + ObjectUtils.nullSafeHashCode(this.getPropertyName());
hashValue = 37 * hashValue + ObjectUtils.nullSafeHashCode(this.getColumnName());
@@ -104,8 +107,8 @@ public class PropertyMapping {
return hashValue;
}
/**
* @inheritDoc
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {

View File

@@ -35,7 +35,7 @@ public class SimpleUserTypeResolver implements UserTypeResolver {
private final Cluster cluster;
/**
* Creates a new {@link SimpleUserTypeResolver}.
* Create a new {@link SimpleUserTypeResolver}.
*
* @param cluster must not be {@literal null}.
* @param keyspaceName must not be empty or {@literal null}.

View File

@@ -37,7 +37,7 @@ public class VerifierMappingExceptions extends MappingException {
private final String className;
/**
* Creates a new {@link VerifierMappingExceptions} for the given {@code entity} and message.
* Create a new {@link VerifierMappingExceptions} for the given {@code entity} and message.
*
* @param entity must not be {@literal null}.
* @param exceptions must not be {@literal null}.
@@ -54,7 +54,7 @@ public class VerifierMappingExceptions extends MappingException {
}
/**
* Creates a new {@link VerifierMappingExceptions} for the given {@code entity} and message.
* Create a new {@link VerifierMappingExceptions} for the given {@code entity} and message.
*
* @param entity must not be {@literal null}.
* @param message

View File

@@ -31,7 +31,7 @@ import org.springframework.util.Assert;
/**
* A bean which represents a Cassandra repository.
*
*
* @author Mark Paluch
*/
public class CassandraRepositoryBean<T> extends CdiRepositoryBean<T> {
@@ -39,7 +39,7 @@ public class CassandraRepositoryBean<T> extends CdiRepositoryBean<T> {
private final Bean<CassandraOperations> cassandraOperationsBean;
/**
* Creates a new {@link CassandraRepositoryBean}.
* Create a new {@link CassandraRepositoryBean}.
*
* @param operations must not be {@literal null}.
* @param qualifiers must not be {@literal null}.

View File

@@ -15,6 +15,8 @@
*/
package org.springframework.data.cassandra.repository.query;
import lombok.RequiredArgsConstructor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -24,9 +26,6 @@ import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.convert.ConversionService;
@@ -48,7 +47,8 @@ import org.springframework.data.repository.query.ReturnedType;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import lombok.RequiredArgsConstructor;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
/**
* Base class for {@link RepositoryQuery} implementations for Cassandra.
@@ -61,11 +61,13 @@ public abstract class AbstractCassandraQuery implements RepositoryQuery {
protected static Logger log = LoggerFactory.getLogger(AbstractCassandraQuery.class);
private final CassandraOperations template;
private final CassandraQueryMethod queryMethod;
private final EntityInstantiators instantiators;
/**
* Creates a new {@link AbstractCassandraQuery} from the given {@link CassandraQueryMethod} and
* Create a new {@link AbstractCassandraQuery} from the given {@link CassandraQueryMethod} and
* {@link CassandraOperations}.
*
* @param queryMethod must not be {@literal null}.

View File

@@ -41,11 +41,13 @@ import org.springframework.util.Assert;
public abstract class AbstractReactiveCassandraQuery implements RepositoryQuery {
private final EntityInstantiators instantiators;
private final ReactiveCassandraOperations operations;
private final ReactiveCassandraQueryMethod method;
/**
* Creates a new {@link AbstractReactiveCassandraQuery} from the given {@link CassandraQueryMethod} and
* Create a new {@link AbstractReactiveCassandraQuery} from the given {@link CassandraQueryMethod} and
* {@link CassandraOperations}.
*
* @param method must not be {@literal null}.

View File

@@ -40,7 +40,7 @@ import org.springframework.util.Assert;
public class CassandraParameters extends Parameters<CassandraParameters, CassandraParameter> {
/**
* Creates a new {@link CassandraParameters} instance from the given {@link Method}
* Create a new {@link CassandraParameters} instance from the given {@link Method}
*
* @param method must not be {@literal null}.
*/

View File

@@ -39,7 +39,7 @@ public class CassandraParametersParameterAccessor extends ParametersParameterAcc
private final List<Object> values;
/**
* Creates a new {@link CassandraParametersParameterAccessor}.
* Create a new {@link CassandraParametersParameterAccessor}.
*
* @param method must not be {@literal null}.
* @param values must not be {@literal null}.

View File

@@ -21,10 +21,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.regex.Pattern;
import com.datastax.driver.core.querybuilder.Clause;
import com.datastax.driver.core.querybuilder.QueryBuilder;
import com.datastax.driver.core.querybuilder.Select;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cassandra.core.cql.CqlIdentifier;
@@ -43,6 +39,10 @@ import org.springframework.data.repository.query.parser.Part.Type;
import org.springframework.data.repository.query.parser.PartTree;
import org.springframework.util.Assert;
import com.datastax.driver.core.querybuilder.Clause;
import com.datastax.driver.core.querybuilder.QueryBuilder;
import com.datastax.driver.core.querybuilder.Select;
/**
* Custom query creator to create Cassandra criteria.
*
@@ -53,16 +53,20 @@ import org.springframework.util.Assert;
class CassandraQueryCreator extends AbstractQueryCreator<Select, Clause> {
private static final Logger LOG = LoggerFactory.getLogger(CassandraQueryCreator.class);
private static final Pattern PUNCTUATION_PATTERN = Pattern.compile("\\p{Punct}");
private final CassandraMappingContext mappingContext;
private final CassandraPersistentEntity<?> entity;
private final CqlIdentifier tableName;
private final WhereBuilder whereBuilder = new WhereBuilder();
/**
* Creates a new {@link CassandraQueryCreator} from the given {@link PartTree}, {@link ConvertingParameterAccessor}
* and {@link MappingContext}.
* Create a new {@link CassandraQueryCreator} from the given {@link PartTree}, {@link ConvertingParameterAccessor} and
* {@link MappingContext}.
*
* @param tree must not be {@literal null}.
* @param accessor must not be {@literal null}.

View File

@@ -17,8 +17,6 @@ package org.springframework.data.cassandra.repository.query;
import java.lang.reflect.Method;
import com.datastax.driver.core.ResultSet;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.dao.InvalidDataAccessApiUsageException;
@@ -34,6 +32,8 @@ import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import com.datastax.driver.core.ResultSet;
/**
* Cassandra specific implementation of {@link QueryMethod}.
*
@@ -51,7 +51,7 @@ public class CassandraQueryMethod extends QueryMethod {
private final Method method;
/**
* Creates a new {@link CassandraQueryMethod} from the given {@link Method}.
* Create a new {@link CassandraQueryMethod} from the given {@link Method}.
*
* @param method must not be {@literal null}.
* @param repositoryMetadata must not be {@literal null}.
@@ -83,7 +83,7 @@ public class CassandraQueryMethod extends QueryMethod {
}
}
/*
/*
* (non-Javadoc)
* @see org.springframework.data.repository.query.QueryMethod#getEntityInformation()
*/

View File

@@ -18,11 +18,6 @@ package org.springframework.data.cassandra.repository.query;
import java.util.Iterator;
import java.util.Set;
import com.datastax.driver.core.CodecRegistry;
import com.datastax.driver.core.DataType;
import com.datastax.driver.core.DataType.CollectionType;
import com.datastax.driver.core.TypeCodec;
import org.springframework.data.cassandra.convert.CassandraConverter;
import org.springframework.data.cassandra.mapping.CassandraMappingContext;
import org.springframework.data.cassandra.mapping.CassandraPersistentProperty;
@@ -33,6 +28,11 @@ import org.springframework.data.domain.Sort;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import com.datastax.driver.core.CodecRegistry;
import com.datastax.driver.core.DataType;
import com.datastax.driver.core.DataType.CollectionType;
import com.datastax.driver.core.TypeCodec;
/**
* Custom {@link org.springframework.data.repository.query.ParameterAccessor} that uses a {@link CassandraConverter} to
* convert parameters.
@@ -45,9 +45,11 @@ class ConvertingParameterAccessor implements CassandraParameterAccessor {
private final static TypeInformation<Set> SET = ClassTypeInformation.from(Set.class);
private final CassandraConverter converter;
private final CassandraParameterAccessor delegate;
ConvertingParameterAccessor(CassandraConverter converter, CassandraParameterAccessor delegate) {
this.converter = converter;
this.delegate = delegate;
}
@@ -225,10 +227,11 @@ class ConvertingParameterAccessor implements CassandraParameterAccessor {
private class ConvertingIterator implements PotentiallyConvertingIterator {
private final Iterator<Object> delegate;
private int index = 0;
/**
* Creates a new {@link ConvertingIterator} for the given delegate.
* Create a new {@link ConvertingIterator} for the given delegate.
*
* @param delegate must not be {@literal null}.
*/

View File

@@ -42,7 +42,7 @@ class DtoInstantiatingConverter implements Converter<Object, Object> {
private final EntityInstantiator instantiator;
/**
* Creates a new {@link Converter} to instantiate DTOs.
* Create a new {@link Converter} to instantiate DTOs.
*
* @param dtoType must not be {@literal null}.
* @param context must not be {@literal null}.

View File

@@ -35,7 +35,7 @@ public class PartTreeCassandraQuery extends AbstractCassandraQuery {
private final PartTree tree;
/**
* Creates a new {@link PartTreeCassandraQuery} from the given {@link QueryMethod} and {@link CassandraTemplate}.
* Create a new {@link PartTreeCassandraQuery} from the given {@link QueryMethod} and {@link CassandraTemplate}.
*
* @param queryMethod must not be {@literal null}.
* @param operations must not be {@literal null}.

View File

@@ -35,7 +35,7 @@ public class ReactiveCassandraQueryMethod extends CassandraQueryMethod {
private final Method method;
/**
* Creates a new {@link ReactiveCassandraQueryMethod} from the given {@link Method}.
* Create a new {@link ReactiveCassandraQueryMethod} from the given {@link Method}.
*
* @param method must not be {@literal null}.
* @param metadata must not be {@literal null}.

View File

@@ -33,7 +33,7 @@ public class ReactivePartTreeCassandraQuery extends AbstractReactiveCassandraQue
private final PartTree tree;
/**
* Creates a new {@link ReactivePartTreeCassandraQuery} from the given {@link ReactiveCassandraQueryMethod} and
* Create a new {@link ReactivePartTreeCassandraQuery} from the given {@link ReactiveCassandraQueryMethod} and
* {@link ReactiveCassandraOperations}.
*
* @param queryMethod must not be {@literal null}.

View File

@@ -15,6 +15,8 @@
*/
package org.springframework.data.cassandra.repository.query;
import reactor.core.publisher.Flux;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cassandra.core.ReactiveSessionCallback;
@@ -27,8 +29,6 @@ import org.springframework.util.Assert;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.CodecRegistry;
import reactor.core.publisher.Flux;
/**
* String-based {@link AbstractCassandraQuery} implementation.
* <p>
@@ -47,7 +47,7 @@ public class ReactiveStringBasedCassandraQuery extends AbstractReactiveCassandra
private final StringBasedQuery stringBasedQuery;
/**
* Creates a new {@link ReactiveStringBasedCassandraQuery} for the given {@link CassandraQueryMethod},
* Create a new {@link ReactiveStringBasedCassandraQuery} for the given {@link CassandraQueryMethod},
* {@link ReactiveCassandraOperations}, {@link SpelExpressionParser}, and {@link EvaluationContextProvider}.
*
* @param queryMethod {@link ReactiveCassandraQueryMethod} on which this query is based.
@@ -64,7 +64,7 @@ public class ReactiveStringBasedCassandraQuery extends AbstractReactiveCassandra
}
/**
* Creates a new {@link ReactiveStringBasedCassandraQuery} for the given {@code query}, {@link CassandraQueryMethod},
* Create a new {@link ReactiveStringBasedCassandraQuery} for the given {@code query}, {@link CassandraQueryMethod},
* {@link ReactiveCassandraOperations}, {@link SpelExpressionParser}, and {@link EvaluationContextProvider}.
*
* @param queryMethod {@link ReactiveCassandraQueryMethod} on which this query is based.

View File

@@ -32,7 +32,7 @@ class SimpleCassandraEntityMetadata<T> implements CassandraEntityMetadata<T> {
private final Class<T> type;
/**
* Creates a new {@link SimpleCassandraEntityMetadata} using the given type and {@link CassandraPersistentEntity} to
* Create a new {@link SimpleCassandraEntityMetadata} using the given type and {@link CassandraPersistentEntity} to
* use for table lookups.
*
* @param type must not be {@literal null}.

View File

@@ -15,10 +15,6 @@
*/
package org.springframework.data.cassandra.repository.query;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.CodecRegistry;
import com.datastax.driver.core.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.cassandra.core.CassandraOperations;
@@ -26,6 +22,10 @@ import org.springframework.data.repository.query.EvaluationContextProvider;
import org.springframework.data.repository.query.QueryCreationException;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.CodecRegistry;
import com.datastax.driver.core.Session;
/**
* String-based {@link AbstractCassandraQuery} implementation.
* <p>
@@ -44,7 +44,7 @@ public class StringBasedCassandraQuery extends AbstractCassandraQuery {
private final StringBasedQuery stringBasedQuery;
/**
* Creates a new {@link StringBasedCassandraQuery} for the given {@link CassandraQueryMethod},
* Create a new {@link StringBasedCassandraQuery} for the given {@link CassandraQueryMethod},
* {@link CassandraOperations}, {@link SpelExpressionParser}, and {@link EvaluationContextProvider}.
*
* @param queryMethod {@link CassandraQueryMethod} on which this query is based.
@@ -60,7 +60,7 @@ public class StringBasedCassandraQuery extends AbstractCassandraQuery {
}
/**
* Creates a new {@link StringBasedCassandraQuery} for the given {@code query}, {@link CassandraQueryMethod},
* Create a new {@link StringBasedCassandraQuery} for the given {@code query}, {@link CassandraQueryMethod},
* {@link CassandraOperations}, {@link SpelExpressionParser}, and {@link EvaluationContextProvider}.
*
* @param query

View File

@@ -47,7 +47,7 @@ class StringBasedQuery {
private final String query;
/**
* Creates a new {@link StringBasedQuery} given {@code query}, {@link ExpressionEvaluatingParameterBinder} and
* Create a new {@link StringBasedQuery} given {@code query}, {@link ExpressionEvaluatingParameterBinder} and
* {@link CodecRegistry}.
*
* @param query must not be empty.

View File

@@ -39,6 +39,24 @@ import org.springframework.util.Assert;
@SuppressWarnings("serial")
public class BasicMapId implements MapId {
private final Map<String, Serializable> map = new HashMap<String, Serializable>();
/**
* Create a new and empty {@link BasicMapId}.
*/
public BasicMapId() {}
/**
* Create a new {@link BasicMapId} given a {@link Map} of key-value tuples.
*
* @param map must not be {@literal null}.
*/
public BasicMapId(Map<String, Serializable> map) {
Assert.notNull(map, "Map must not be null");
this.map.putAll(map);
}
/**
* Factory method. Convenient if imported statically.
*
@@ -66,42 +84,50 @@ public class BasicMapId implements MapId {
return new BasicMapId(id);
}
protected Map<String, Serializable> map = new HashMap<String, Serializable>();
public BasicMapId() {}
public BasicMapId(Map<String, Serializable> map) {
Assert.notNull(map, "Map must not be null");
this.map.putAll(map);
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.repository.MapId#with(java.lang.String, java.io.Serializable)
*/
@Override
public BasicMapId with(String name, Serializable value) {
put(name, value);
return this;
}
/* (non-Javadoc)
* @see java.util.Map#clear()
*/
@Override
public void clear() {
map.clear();
}
/* (non-Javadoc)
* @see java.util.Map#containsKey(java.lang.Object)
*/
@Override
public boolean containsKey(Object name) {
return map.containsKey(name);
}
/* (non-Javadoc)
* @see java.util.Map#containsValue(java.lang.Object)
*/
@Override
public boolean containsValue(Object value) {
return map.containsValue(value);
}
/* (non-Javadoc)
* @see java.util.Map#entrySet()
*/
@Override
public Set<java.util.Map.Entry<String, Serializable>> entrySet() {
return map.entrySet();
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object that) {
if (this == that) {
@@ -116,51 +142,81 @@ public class BasicMapId implements MapId {
return map.equals(that);
}
/* (non-Javadoc)
* @see java.util.Map#get(java.lang.Object)
*/
@Override
public Serializable get(Object name) {
return map.get(name);
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return map.hashCode();
}
/* (non-Javadoc)
* @see java.util.Map#isEmpty()
*/
@Override
public boolean isEmpty() {
return map.isEmpty();
}
/* (non-Javadoc)
* @see java.util.Map#keySet()
*/
@Override
public Set<String> keySet() {
return map.keySet();
}
/* (non-Javadoc)
* @see java.util.Map#put(java.lang.Object, java.lang.Object)
*/
@Override
public Serializable put(String name, Serializable value) {
return map.put(name, value);
}
/* (non-Javadoc)
* @see java.util.Map#putAll(java.util.Map)
*/
@Override
public void putAll(Map<? extends String, ? extends Serializable> source) {
map.putAll(source);
}
/* (non-Javadoc)
* @see java.util.Map#remove(java.lang.Object)
*/
@Override
public Serializable remove(Object name) {
return map.remove(name);
}
/* (non-Javadoc)
* @see java.util.Map#size()
*/
@Override
public int size() {
return map.size();
}
/* (non-Javadoc)
* @see java.util.Map#values()
*/
@Override
public Collection<Serializable> values() {
return map.values();
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {

View File

@@ -53,10 +53,11 @@ public class CassandraRepositoryFactory extends RepositoryFactorySupport {
private static final SpelExpressionParser EXPRESSION_PARSER = new SpelExpressionParser();
private final CassandraMappingContext mappingContext;
private final CassandraOperations operations;
/**
* Creates a new {@link CassandraRepositoryFactory} with the given {@link CassandraOperations}.
* Create a new {@link CassandraRepositoryFactory} with the given {@link CassandraOperations}.
*
* @param operations must not be {@literal null}
*/

View File

@@ -38,10 +38,10 @@ public class CassandraRepositoryFactoryBean<T extends Repository<S, ID>, S, ID e
extends RepositoryFactoryBeanSupport<T, S, ID> {
private CassandraTemplate cassandraTemplate;
/**
* Creates a new {@link CassandraRepositoryFactoryBean} for the given repository interface.
*
* Create a new {@link CassandraRepositoryFactoryBean} for the given repository interface.
*
* @param repositoryInterface must not be {@literal null}.
*/
public CassandraRepositoryFactoryBean(Class<? extends T> repositoryInterface) {

View File

@@ -41,7 +41,7 @@ public class MappingCassandraEntityInformation<T, ID extends Serializable> exten
private CassandraConverter converter;
/**
* Creates a new {@link MappingCassandraEntityInformation} for the given {@link CassandraPersistentEntity}.
* Create a new {@link MappingCassandraEntityInformation} for the given {@link CassandraPersistentEntity}.
*
* @param entity must not be {@literal null}.
*/
@@ -53,6 +53,9 @@ public class MappingCassandraEntityInformation<T, ID extends Serializable> exten
this.converter = converter;
}
/* (non-Javadoc)
* @see org.springframework.data.repository.core.EntityInformation#getId(java.lang.Object)
*/
@SuppressWarnings("unchecked")
@Override
public ID getId(T entity) {
@@ -68,6 +71,9 @@ public class MappingCassandraEntityInformation<T, ID extends Serializable> exten
return (ID) converter.getId(entity, entityMetadata);
}
/* (non-Javadoc)
* @see org.springframework.data.repository.core.EntityInformation#getIdType()
*/
@SuppressWarnings("unchecked")
@Override
public Class<ID> getIdType() {
@@ -75,6 +81,9 @@ public class MappingCassandraEntityInformation<T, ID extends Serializable> exten
: entityMetadata.getIdProperty().getType());
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.repository.query.CassandraEntityMetadata#getTableName()
*/
@Override
public CqlIdentifier getTableName() {
return entityMetadata.getTableName();

View File

@@ -52,7 +52,7 @@ public class ReactiveCassandraRepositoryFactory extends ReactiveRepositoryFactor
private final CassandraMappingContext mappingContext;
/**
* Creates a new {@link ReactiveCassandraRepositoryFactory} with the given {@link ReactiveCassandraOperations}.
* Create a new {@link ReactiveCassandraRepositoryFactory} with the given {@link ReactiveCassandraOperations}.
*
* @param cassandraOperations must not be {@literal null}.
*/

View File

@@ -40,10 +40,10 @@ public class ReactiveCassandraRepositoryFactoryBean<T extends Repository<S, ID>,
private boolean mappingContextConfigured = false;
private ReactiveCassandraOperations operations;
/**
* Creates a new {@link ReactiveCassandraRepositoryFactoryBean} for the given repository interface.
*
* Create a new {@link ReactiveCassandraRepositoryFactoryBean} for the given repository interface.
*
* @param repositoryInterface must not be {@literal null}.
*/
public ReactiveCassandraRepositoryFactoryBean(Class<? extends T> repositoryInterface) {

View File

@@ -38,10 +38,11 @@ import com.datastax.driver.core.querybuilder.Select;
public class SimpleCassandraRepository<T, ID extends Serializable> implements TypedIdCassandraRepository<T, ID> {
private CassandraOperations operations;
private CassandraEntityInformation<T, ID> entityInformation;
/**
* Creates a new {@link SimpleCassandraRepository} for the given {@link CassandraEntityInformation} and
* Create a new {@link SimpleCassandraRepository} for the given {@link CassandraEntityInformation} and
* {@link CassandraTemplate}.
*
* @param metadata must not be {@literal null}.
@@ -56,51 +57,81 @@ public class SimpleCassandraRepository<T, ID extends Serializable> implements Ty
this.operations = operations;
}
/* (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#save(S)
*/
@Override
public <S extends T> S save(S entity) {
return operations.insert(entity);
}
/* (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#save(java.lang.Iterable)
*/
@Override
public <S extends T> List<S> save(Iterable<S> entities) {
return operations.insert(CollectionUtils.toList(entities));
}
/* (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#findOne(java.io.Serializable)
*/
@Override
public T findOne(ID id) {
return operations.selectOneById(id, entityInformation.getJavaType());
}
/* (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#exists(java.io.Serializable)
*/
@Override
public boolean exists(ID id) {
return operations.exists(id, entityInformation.getJavaType());
}
/* (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#count()
*/
@Override
public long count() {
return operations.count(entityInformation.getJavaType());
}
/* (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#delete(java.io.Serializable)
*/
@Override
public void delete(ID id) {
operations.deleteById(id, entityInformation.getJavaType());
}
/* (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#delete(java.lang.Object)
*/
@Override
public void delete(T entity) {
delete(entityInformation.getId(entity));
}
/* (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#delete(java.lang.Iterable)
*/
@Override
public void delete(Iterable<? extends T> entities) {
operations.delete(CollectionUtils.toList(entities));
}
/* (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#deleteAll()
*/
@Override
public void deleteAll() {
operations.truncate(entityInformation.getJavaType());
}
/* (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#findAll()
*/
@Override
public List<T> findAll() {
@@ -109,6 +140,9 @@ public class SimpleCassandraRepository<T, ID extends Serializable> implements Ty
return operations.select(select, entityInformation.getJavaType());
}
/* (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#findAll(java.lang.Iterable)
*/
@Override
public Iterable<T> findAll(Iterable<ID> ids) {
return operations.selectBySimpleIds(ids, entityInformation.getJavaType());

View File

@@ -15,6 +15,9 @@
*/
package org.springframework.data.cassandra.repository.support;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.io.Serializable;
import org.reactivestreams.Publisher;
@@ -26,9 +29,6 @@ import org.springframework.util.Assert;
import com.datastax.driver.core.querybuilder.QueryBuilder;
import com.datastax.driver.core.querybuilder.Select;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/**
* Reactive repository base implementation for Cassandra.
*
@@ -42,7 +42,7 @@ public class SimpleReactiveCassandraRepository<T, ID extends Serializable>
protected CassandraEntityInformation<T, ID> entityInformation;
/**
* Creates a new {@link SimpleReactiveCassandraRepository} for the given {@link CassandraEntityInformation} and
* Create a new {@link SimpleReactiveCassandraRepository} for the given {@link CassandraEntityInformation} and
* {@link ReactiveCassandraOperations}.
*
* @param metadata must not be {@literal null}.

View File

@@ -29,15 +29,15 @@ import com.datastax.driver.core.Row;
/**
* Utility to mock a Cassandra {@link Row}.
*
*
* @author Mark Paluch
*/
public class RowMockUtil {
/**
* Creates a new {@link Row} mock using the given {@code columns}. Each column carries a name, value and data type so
* Create a new {@link Row} mock using the given {@code columns}. Each column carries a name, value and data type so
* users of {@link Row} can use most of the methods.
*
*
* @param columns
* @return
*/
@@ -126,8 +126,8 @@ public class RowMockUtil {
}
/**
* Creates a new {@link Column} to be used with {@link RowMockUtil#newRowMock(Column...)}.
*
* Create a new {@link Column} to be used with {@link RowMockUtil#newRowMock(Column...)}.
*
* @param name must not be empty or {@link null}.
* @param value can be {@literal null}.
* @param type must not be {@literal null}.

View File

@@ -31,6 +31,7 @@ import org.springframework.cassandra.core.cql.CqlIdentifier;
* Unit tests for {@link BasicCassandraMappingContext}.
*
* @author Matthew T. Adams
* @author Mark Paluch
*/
public class ForceQuotedPropertiesSimpleUnitTests {
@@ -43,6 +44,7 @@ public class ForceQuotedPropertiesSimpleUnitTests {
@Test
public void testImplicit() {
CassandraPersistentEntity<?> entity = context.getPersistentEntity(Implicit.class);
CassandraPersistentProperty primaryKey = entity.getPersistentProperty("primaryKey");
@@ -62,6 +64,7 @@ public class ForceQuotedPropertiesSimpleUnitTests {
@Test
public void testDefault() {
CassandraPersistentEntity<?> entity = context.getPersistentEntity(Default.class);
CassandraPersistentProperty primaryKey = entity.getPersistentProperty("primaryKey");
@@ -81,6 +84,7 @@ public class ForceQuotedPropertiesSimpleUnitTests {
@Test
public void testExplicit() {
CassandraPersistentEntity<?> entity = context.getPersistentEntity(Explicit.class);
CassandraPersistentProperty primaryKey = entity.getPersistentProperty("primaryKey");
@@ -100,6 +104,7 @@ public class ForceQuotedPropertiesSimpleUnitTests {
@Test
public void testImplicitComposite() {
CassandraPersistentEntity<?> key = context.getPersistentEntity(ImplicitKey.class);
CassandraPersistentProperty stringZero = key.getPersistentProperty("stringZero");
@@ -135,13 +140,14 @@ public class ForceQuotedPropertiesSimpleUnitTests {
@Test
public void testDefaultComposite() {
CassandraPersistentEntity<?> key = context.getPersistentEntity(DefaultKey.class);
CassandraPersistentProperty stringZero = key.getPersistentProperty("stringZero");
CassandraPersistentProperty stringOne = key.getPersistentProperty("stringOne");
assertThat(stringZero.getColumnName().equals("stringZero")).isTrue();
assertThat(stringOne.getColumnName().equals("stringOne")).isTrue();
assertThat(stringZero.getColumnName()).isEqualTo(CqlIdentifier.cqlId("stringZero"));
assertThat(stringOne.getColumnName()).isEqualTo(CqlIdentifier.cqlId("stringOne"));
assertThat(stringZero.getColumnName().toCql()).isEqualTo("stringzero");
assertThat(stringOne.getColumnName().toCql()).isEqualTo("stringone");
@@ -171,11 +177,16 @@ public class ForceQuotedPropertiesSimpleUnitTests {
@Test
public void testExplicitComposite() {
CassandraPersistentEntity<?> key = context.getPersistentEntity(ExplicitKey.class);
CassandraPersistentProperty stringZero = key.getPersistentProperty("stringZero");
CassandraPersistentProperty stringOne = key.getPersistentProperty("stringOne");
assertThat(stringZero.getColumnName()) //
.isEqualTo(CqlIdentifier.cqlId("TheFirstKeyField", true)) //
.isNotEqualTo(CqlIdentifier.cqlId("TheFirstKeyField"));
assertThat(stringZero.getColumnName().toCql()).isEqualTo("\"" + EXPLICIT_KEY_0 + "\"");
assertThat(stringOne.getColumnName().toCql()).isEqualTo("\"" + EXPLICIT_KEY_1 + "\"");

View File

@@ -29,7 +29,7 @@ import com.datastax.driver.core.DataType;
/**
* Simple {@link ParameterAccessor} that returns the given parameters unfiltered.
*
*
* @author Mark Paluch
*/
class StubParameterAccessor implements CassandraParameterAccessor {
@@ -37,7 +37,7 @@ class StubParameterAccessor implements CassandraParameterAccessor {
private final Object[] values;
/**
* Creates a new {@link ConvertingParameterAccessor} backed by a {@link StubParameterAccessor} simply returning the
* Create a new {@link ConvertingParameterAccessor} backed by a {@link StubParameterAccessor} simply returning the
* given parameters converted but unfiltered.
*
* @param converter