DATACASS-393 - Remove references to Assert single-arg methods.
Replace references to Assert single-arg methods with references to methods accepting the test object and message. Related ticket: SPR-15196.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 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.
|
||||
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package org.springframework.cassandra.core;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -34,9 +37,6 @@ import com.datastax.driver.core.exceptions.DriverException;
|
||||
import com.datastax.driver.core.policies.RetryPolicy;
|
||||
import com.datastax.driver.core.querybuilder.QueryBuilder;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* <b>This is the central class in the CQL core package for reactive Cassandra data access.</b> It simplifies the use of
|
||||
* CQL and helps to avoid common errors. It executes core CQL workflow, leaving application code to provide CQL and
|
||||
@@ -682,7 +682,7 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
|
||||
*/
|
||||
protected <T> Flux<T> createFlux(Statement statement, ReactiveStatementCallback<T> callback) {
|
||||
|
||||
Assert.notNull(callback);
|
||||
Assert.notNull(callback, "ReactiveStatementCallback must not be null");
|
||||
|
||||
applyStatementSettings(statement);
|
||||
|
||||
@@ -699,7 +699,7 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
|
||||
*/
|
||||
protected <T> Mono<T> createMono(Statement statement, ReactiveStatementCallback<T> callback) {
|
||||
|
||||
Assert.notNull(callback);
|
||||
Assert.notNull(callback, "ReactiveStatementCallback must not be null");
|
||||
|
||||
applyStatementSettings(statement);
|
||||
|
||||
@@ -716,7 +716,7 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
|
||||
*/
|
||||
protected <T> Flux<T> createFlux(ReactiveSessionCallback<T> callback) {
|
||||
|
||||
Assert.notNull(callback);
|
||||
Assert.notNull(callback, "ReactiveStatementCallback must not be null");
|
||||
|
||||
ReactiveSession session = getSession();
|
||||
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2017 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.cassandra.core;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
@@ -5,9 +20,9 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* CQL keywords.
|
||||
*
|
||||
* @see <a
|
||||
* href="http://cassandra.apache.org/doc/cql3/CQL.html#appendixA">http://cassandra.apache.org/doc/cql3/CQL.html#appendixA</a>
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public enum ReservedKeyword {
|
||||
@@ -64,7 +79,9 @@ public enum ReservedKeyword {
|
||||
* @see ReservedKeyword#isReserved(String)
|
||||
*/
|
||||
public static boolean isReserved(CharSequence candidate) {
|
||||
Assert.notNull(candidate);
|
||||
|
||||
Assert.notNull(candidate, "CharSequence must not be null");
|
||||
|
||||
return isReserved(candidate.toString());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2017 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.cassandra.core.converter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -10,6 +25,11 @@ import org.springframework.util.Assert;
|
||||
import com.datastax.driver.core.ResultSet;
|
||||
import com.datastax.driver.core.Row;
|
||||
|
||||
/**
|
||||
* {@link Converter} from {@link ResultSet} to {@link Object} array.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class ResultSetToArrayConverter implements Converter<ResultSet, Object[]> {
|
||||
|
||||
protected Converter<Row, Object[]> rowConverter;
|
||||
@@ -24,7 +44,7 @@ public class ResultSetToArrayConverter implements Converter<ResultSet, Object[]>
|
||||
|
||||
public void setRowConverter(Converter<Row, Object[]> rowConverter) {
|
||||
|
||||
Assert.notNull(rowConverter);
|
||||
Assert.notNull(rowConverter, "Converter must not be null");
|
||||
this.rowConverter = rowConverter;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2017 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.cassandra.core.converter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -11,6 +26,11 @@ import org.springframework.util.Assert;
|
||||
import com.datastax.driver.core.ResultSet;
|
||||
import com.datastax.driver.core.Row;
|
||||
|
||||
/**
|
||||
* {@link Converter} from {@link ResultSet} to {@link Map}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class ResultSetToListConverter implements Converter<ResultSet, List<Map<String, Object>>> {
|
||||
|
||||
protected Converter<Row, Map<String, Object>> rowConverter = new RowToMapConverter();
|
||||
@@ -27,7 +47,8 @@ public class ResultSetToListConverter implements Converter<ResultSet, List<Map<S
|
||||
|
||||
public void setRowConverter(Converter<Row, Map<String, Object>> rowConverter) {
|
||||
|
||||
Assert.notNull(rowConverter);
|
||||
Assert.notNull(rowConverter, "Converter must not be null");
|
||||
|
||||
this.rowConverter = rowConverter;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2017 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.cassandra.core.cql;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
@@ -10,7 +25,7 @@ import org.springframework.util.Assert;
|
||||
* <p/>
|
||||
* Keyspace identifiers are converted to lower case. To render, use any of the methods {@link #toCql()},
|
||||
* {@link #toCql(StringBuilder)}, or {@link #toString()}.
|
||||
*
|
||||
*
|
||||
* @see #KeyspaceIdentifier(String)
|
||||
* @see #toCql()
|
||||
* @see #toCql(StringBuilder)
|
||||
@@ -50,14 +65,14 @@ public final class KeyspaceIdentifier implements Comparable<KeyspaceIdentifier>
|
||||
*/
|
||||
private void setIdentifier(CharSequence identifier) {
|
||||
|
||||
Assert.notNull(identifier);
|
||||
Assert.notNull(identifier, "Identifier must not be null");
|
||||
|
||||
String string = identifier.toString();
|
||||
Assert.hasText(string);
|
||||
Assert.hasText(string, "Identifier must not be empty");
|
||||
|
||||
if (!isIdentifier(string)) {
|
||||
throw new IllegalArgumentException(String.format("given string [%s] is not a valid keyspace identifier",
|
||||
identifier));
|
||||
throw new IllegalArgumentException(
|
||||
String.format("given string [%s] is not a valid keyspace identifier", identifier));
|
||||
}
|
||||
this.identifier = string.toLowerCase();
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -20,7 +20,7 @@ import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Base class for column change CQL generators.
|
||||
*
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
* @param <T> The corresponding {@link ColumnChangeSpecification} type for this CQL generator.
|
||||
*/
|
||||
@@ -35,7 +35,8 @@ public abstract class ColumnChangeCqlGenerator<T extends ColumnChangeSpecificati
|
||||
}
|
||||
|
||||
protected void setSpecification(ColumnChangeSpecification specification) {
|
||||
Assert.notNull(specification);
|
||||
|
||||
Assert.notNull(specification, "ColumnChangeSpecification must not be null");
|
||||
this.specification = specification;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -18,6 +18,12 @@ package org.springframework.cassandra.core.cql.generator;
|
||||
import org.springframework.cassandra.core.keyspace.IndexNameSpecification;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Base class for Index CQL generators.
|
||||
*
|
||||
* @param <T> subtype of {@link IndexNameSpecification}.
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public abstract class IndexNameCqlGenerator<T extends IndexNameSpecification<T>> {
|
||||
|
||||
public abstract StringBuilder toCql(StringBuilder cql);
|
||||
@@ -29,7 +35,8 @@ public abstract class IndexNameCqlGenerator<T extends IndexNameSpecification<T>>
|
||||
}
|
||||
|
||||
protected void setSpecification(IndexNameSpecification<T> specification) {
|
||||
Assert.notNull(specification);
|
||||
|
||||
Assert.notNull(specification, "IndexNameSpecification must not be null");
|
||||
this.specification = specification;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -19,9 +19,9 @@ import org.springframework.cassandra.core.keyspace.KeyspaceSpecification;
|
||||
|
||||
/**
|
||||
* Base class that contains behavior common to CQL generation for table operations.
|
||||
*
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
* @param T The subtype of this class for which this is a CQL generator.
|
||||
* @param <T> subtype of this class for which this is a CQL generator.
|
||||
*/
|
||||
public abstract class KeyspaceCqlGenerator<T extends KeyspaceSpecification<T>> extends
|
||||
KeyspaceOptionsCqlGenerator<KeyspaceSpecification<T>> {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -18,6 +18,12 @@ package org.springframework.cassandra.core.cql.generator;
|
||||
import org.springframework.cassandra.core.keyspace.KeyspaceActionSpecification;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Base class for Keyspace CQL generators.
|
||||
*
|
||||
* @param <T> subtype of {@link KeyspaceActionSpecification}.
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public abstract class KeyspaceNameCqlGenerator<T extends KeyspaceActionSpecification<T>> {
|
||||
|
||||
public abstract StringBuilder toCql(StringBuilder cql);
|
||||
@@ -29,7 +35,8 @@ public abstract class KeyspaceNameCqlGenerator<T extends KeyspaceActionSpecifica
|
||||
}
|
||||
|
||||
protected void setSpecification(KeyspaceActionSpecification<T> specification) {
|
||||
Assert.notNull(specification);
|
||||
|
||||
Assert.notNull(specification, "KeyspaceActionSpecification must not be null");
|
||||
this.specification = specification;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -18,6 +18,12 @@ package org.springframework.cassandra.core.cql.generator;
|
||||
import org.springframework.cassandra.core.keyspace.TableNameSpecification;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Base class for Table CQL generators.
|
||||
*
|
||||
* @param <T> subtype of TableNameSpecification.
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public abstract class TableNameCqlGenerator<T extends TableNameSpecification<T>> {
|
||||
|
||||
public abstract StringBuilder toCql(StringBuilder cql);
|
||||
@@ -29,7 +35,8 @@ public abstract class TableNameCqlGenerator<T extends TableNameSpecification<T>>
|
||||
}
|
||||
|
||||
protected void setSpecification(TableNameSpecification<T> specification) {
|
||||
Assert.notNull(specification);
|
||||
|
||||
Assert.notNull(specification, "TableNameSpecification must not be null");
|
||||
this.specification = specification;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -15,11 +15,10 @@
|
||||
*/
|
||||
package org.springframework.cassandra.core.keyspace;
|
||||
|
||||
import static org.springframework.cassandra.core.Ordering.ASCENDING;
|
||||
import static org.springframework.cassandra.core.PrimaryKeyType.CLUSTERED;
|
||||
import static org.springframework.cassandra.core.PrimaryKeyType.PARTITIONED;
|
||||
import static org.springframework.cassandra.core.cql.CqlIdentifier.cqlId;
|
||||
import static org.springframework.cassandra.core.cql.CqlStringUtils.noNull;
|
||||
import static org.springframework.cassandra.core.Ordering.*;
|
||||
import static org.springframework.cassandra.core.PrimaryKeyType.*;
|
||||
import static org.springframework.cassandra.core.cql.CqlIdentifier.*;
|
||||
import static org.springframework.cassandra.core.cql.CqlStringUtils.*;
|
||||
|
||||
import org.springframework.cassandra.core.Ordering;
|
||||
import org.springframework.cassandra.core.PrimaryKeyType;
|
||||
@@ -35,7 +34,7 @@ import com.datastax.driver.core.DataType;
|
||||
* a clustered <code>PRIMARY KEY</code> column, use {@link #clustered()} or {@link #clustered(Ordering)}. To specify
|
||||
* that the <code>PRIMARY KEY</code> column is or is part of the partition key, use {@link #partitioned()} instead of
|
||||
* {@link #clustered()} or {@link #clustered(Ordering)}.
|
||||
*
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
@@ -53,7 +52,7 @@ public class ColumnSpecification {
|
||||
|
||||
/**
|
||||
* Sets the column's name.
|
||||
*
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public ColumnSpecification name(String name) {
|
||||
@@ -61,14 +60,15 @@ public class ColumnSpecification {
|
||||
}
|
||||
|
||||
public ColumnSpecification name(CqlIdentifier name) {
|
||||
Assert.notNull(name);
|
||||
|
||||
Assert.notNull(name, "CqlIdentifier must not be null");
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the column's type.
|
||||
*
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public ColumnSpecification type(DataType type) {
|
||||
@@ -79,7 +79,7 @@ public class ColumnSpecification {
|
||||
/**
|
||||
* Identifies this column as a primary key column that is also part of a partition key. Sets the column's
|
||||
* {@link #keyType} to {@link PrimaryKeyType#PARTITIONED} and its {@link #ordering} to <code>null</code>.
|
||||
*
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public ColumnSpecification partitioned() {
|
||||
@@ -90,7 +90,7 @@ public class ColumnSpecification {
|
||||
* Toggles the identification of this column as a primary key column that also is or is part of a partition key. Sets
|
||||
* {@link #ordering} to <code>null</code> and, if the given boolean is <code>true</code>, then sets the column's
|
||||
* {@link #keyType} to {@link PrimaryKeyType#PARTITIONED}, else sets it to <code>null</code>.
|
||||
*
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public ColumnSpecification partitioned(boolean partitioned) {
|
||||
@@ -102,7 +102,7 @@ public class ColumnSpecification {
|
||||
/**
|
||||
* Identifies this column as a clustered key column with default ordering. Sets the column's {@link #keyType} to
|
||||
* {@link PrimaryKeyType#CLUSTERED} and its {@link #ordering} to {@link #DEFAULT_ORDERING}.
|
||||
*
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public ColumnSpecification clustered() {
|
||||
@@ -112,7 +112,7 @@ public class ColumnSpecification {
|
||||
/**
|
||||
* Identifies this column as a clustered key column with the given ordering. Sets the column's {@link #keyType} to
|
||||
* {@link PrimaryKeyType#CLUSTERED} and its {@link #ordering} to the given {@link Ordering}.
|
||||
*
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public ColumnSpecification clustered(Ordering order) {
|
||||
@@ -123,7 +123,7 @@ public class ColumnSpecification {
|
||||
* Toggles the identification of this column as a clustered key column. If the given boolean is <code>true</code>,
|
||||
* then sets the column's {@link #keyType} to {@link PrimaryKeyType#PARTITIONED} and {@link #ordering} to the given
|
||||
* {@link Ordering} , else sets both {@link #keyType} and {@link #ordering} to <code>null</code>.
|
||||
*
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public ColumnSpecification clustered(Ordering order, boolean primary) {
|
||||
@@ -134,7 +134,7 @@ public class ColumnSpecification {
|
||||
|
||||
/**
|
||||
* Sets the column's {@link #keyType}.
|
||||
*
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
ColumnSpecification keyType(PrimaryKeyType keyType) {
|
||||
@@ -144,7 +144,7 @@ public class ColumnSpecification {
|
||||
|
||||
/**
|
||||
* Sets the column's {@link #ordering}.
|
||||
*
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
ColumnSpecification ordering(Ordering ordering) {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.cassandra.core.keyspace;
|
||||
|
||||
import static org.springframework.cassandra.core.cql.CqlIdentifier.cqlId;
|
||||
import static org.springframework.cassandra.core.cql.CqlIdentifier.*;
|
||||
|
||||
import org.springframework.cassandra.core.cql.CqlIdentifier;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -23,12 +23,12 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Builder class to construct a <code>CREATE INDEX</code> specification.
|
||||
*
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
* @author David Webb
|
||||
*/
|
||||
public class CreateIndexSpecification extends IndexNameSpecification<CreateIndexSpecification> implements
|
||||
IndexDescriptor {
|
||||
public class CreateIndexSpecification extends IndexNameSpecification<CreateIndexSpecification>
|
||||
implements IndexDescriptor {
|
||||
|
||||
/**
|
||||
* Entry point into the {@link CreateIndexSpecification}'s fluent API to create a index. Convenient if imported
|
||||
@@ -62,7 +62,7 @@ public class CreateIndexSpecification extends IndexNameSpecification<CreateIndex
|
||||
|
||||
/**
|
||||
* Causes the inclusion of an <code>IF NOT EXISTS</code> clause.
|
||||
*
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public CreateIndexSpecification ifNotExists() {
|
||||
@@ -71,7 +71,7 @@ public class CreateIndexSpecification extends IndexNameSpecification<CreateIndex
|
||||
|
||||
/**
|
||||
* Toggles the inclusion of an <code>IF NOT EXISTS</code> clause.
|
||||
*
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public CreateIndexSpecification ifNotExists(boolean ifNotExists) {
|
||||
@@ -113,7 +113,7 @@ public class CreateIndexSpecification extends IndexNameSpecification<CreateIndex
|
||||
|
||||
/**
|
||||
* Sets the table name.
|
||||
*
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public CreateIndexSpecification tableName(String tableName) {
|
||||
@@ -121,7 +121,9 @@ public class CreateIndexSpecification extends IndexNameSpecification<CreateIndex
|
||||
}
|
||||
|
||||
public CreateIndexSpecification tableName(CqlIdentifier tableName) {
|
||||
Assert.notNull(tableName);
|
||||
|
||||
Assert.notNull(tableName, "CqlIdentifier must not be null");
|
||||
|
||||
this.tableName = tableName;
|
||||
return this;
|
||||
}
|
||||
@@ -136,7 +138,9 @@ public class CreateIndexSpecification extends IndexNameSpecification<CreateIndex
|
||||
}
|
||||
|
||||
public CreateIndexSpecification columnName(CqlIdentifier columnName) {
|
||||
Assert.notNull(columnName);
|
||||
|
||||
Assert.notNull(columnName, "CqlIdentifier must not be null");
|
||||
|
||||
this.columnName = columnName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.cassandra.core.keyspace;
|
||||
|
||||
import static org.springframework.cassandra.core.cql.CqlStringUtils.escapeSingle;
|
||||
import static org.springframework.cassandra.core.cql.CqlStringUtils.singleQuote;
|
||||
import static org.springframework.cassandra.core.cql.CqlStringUtils.*;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@@ -27,7 +26,7 @@ import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A default implementation of {@link Option}.
|
||||
*
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class DefaultOption implements Option {
|
||||
@@ -48,7 +47,8 @@ public class DefaultOption implements Option {
|
||||
}
|
||||
|
||||
protected void setName(String name) {
|
||||
Assert.hasLength(name);
|
||||
|
||||
Assert.hasText(name, "Name must not be null or empty");
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@@ -137,8 +137,8 @@ public class DefaultOption implements Option {
|
||||
return;
|
||||
}
|
||||
// else value is not coerceable into the expected type
|
||||
throw new IllegalArgumentException("Option [" + getName() + "] takes value coerceable to type ["
|
||||
+ getType().getName() + "]");
|
||||
throw new IllegalArgumentException(
|
||||
"Option [" + getName() + "] takes value coerceable to type [" + getType().getName() + "]");
|
||||
}
|
||||
// else this option doesn't take a value
|
||||
if (value != null) {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -15,17 +15,18 @@
|
||||
*/
|
||||
package org.springframework.cassandra.core.keyspace;
|
||||
|
||||
import static org.springframework.cassandra.core.cql.CqlIdentifier.cqlId;
|
||||
import static org.springframework.cassandra.core.cql.CqlIdentifier.*;
|
||||
|
||||
import org.springframework.cassandra.core.cql.CqlIdentifier;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Abstract builder class to support the construction of an index.
|
||||
*
|
||||
*
|
||||
* @param <T> The subtype of the {@link IndexNameSpecification}
|
||||
* @author David Webb
|
||||
* @author Matthew T. Adams
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public abstract class IndexNameSpecification<T extends IndexNameSpecification<T>> {
|
||||
|
||||
@@ -36,7 +37,7 @@ public abstract class IndexNameSpecification<T extends IndexNameSpecification<T>
|
||||
|
||||
/**
|
||||
* Sets the index name.
|
||||
*
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public T name(String name) {
|
||||
@@ -45,7 +46,8 @@ public abstract class IndexNameSpecification<T extends IndexNameSpecification<T>
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T name(CqlIdentifier name) {
|
||||
Assert.notNull(name);
|
||||
|
||||
Assert.notNull(name, "CqlIdentifier must not be null");
|
||||
this.name = name;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -15,14 +15,14 @@
|
||||
*/
|
||||
package org.springframework.cassandra.core.keyspace;
|
||||
|
||||
import static org.springframework.cassandra.core.cql.KeyspaceIdentifier.ksId;
|
||||
import static org.springframework.cassandra.core.cql.KeyspaceIdentifier.*;
|
||||
|
||||
import org.springframework.cassandra.core.cql.KeyspaceIdentifier;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Abstract builder class to support the construction of keyspace specifications.
|
||||
*
|
||||
*
|
||||
* @author John McPeek
|
||||
* @author David Webb
|
||||
* @param <T> The subtype of the {@link KeyspaceActionSpecification}
|
||||
@@ -36,7 +36,7 @@ public abstract class KeyspaceActionSpecification<T extends KeyspaceActionSpecif
|
||||
|
||||
/**
|
||||
* Sets the keyspace name.
|
||||
*
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public T name(String name) {
|
||||
@@ -45,12 +45,14 @@ public abstract class KeyspaceActionSpecification<T extends KeyspaceActionSpecif
|
||||
|
||||
/**
|
||||
* Sets the keyspace name.
|
||||
*
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public T name(KeyspaceIdentifier name) {
|
||||
Assert.notNull(name);
|
||||
|
||||
Assert.notNull(name, "KeyspaceIdentifier must not be null");
|
||||
|
||||
this.name = name;
|
||||
return (T) this;
|
||||
}
|
||||
@@ -61,7 +63,7 @@ public abstract class KeyspaceActionSpecification<T extends KeyspaceActionSpecif
|
||||
|
||||
/**
|
||||
* Determine the KeyspaceActionSpecifications are the same if they have the same "name" and same class.
|
||||
*
|
||||
*
|
||||
* @param that The object to compare this to.
|
||||
* @return Are this and that the same?
|
||||
*/
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -15,14 +15,14 @@
|
||||
*/
|
||||
package org.springframework.cassandra.core.keyspace;
|
||||
|
||||
import static org.springframework.cassandra.core.cql.CqlIdentifier.cqlId;
|
||||
import static org.springframework.cassandra.core.cql.CqlIdentifier.*;
|
||||
|
||||
import org.springframework.cassandra.core.cql.CqlIdentifier;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Abstract builder class to support the construction of table specifications.
|
||||
*
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
* @param <T> The subtype of the {@link TableNameSpecification}
|
||||
*/
|
||||
@@ -35,7 +35,7 @@ public abstract class TableNameSpecification<T extends TableNameSpecification<T>
|
||||
|
||||
/**
|
||||
* Sets the table name.
|
||||
*
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public T name(String name) {
|
||||
@@ -44,7 +44,8 @@ public abstract class TableNameSpecification<T extends TableNameSpecification<T>
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T name(CqlIdentifier name) {
|
||||
Assert.notNull(name);
|
||||
|
||||
Assert.notNull(name, "CqlIdentifier must not be null");
|
||||
this.name = name;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors
|
||||
*
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -17,7 +17,6 @@ package org.springframework.data.cassandra.convert;
|
||||
|
||||
import org.springframework.data.cassandra.mapping.CassandraPersistentProperty;
|
||||
import org.springframework.data.mapping.model.DefaultSpELExpressionEvaluator;
|
||||
import org.springframework.data.mapping.model.PropertyValueProvider;
|
||||
import org.springframework.data.mapping.model.SpELExpressionEvaluator;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -25,7 +24,7 @@ import com.datastax.driver.core.Row;
|
||||
|
||||
/**
|
||||
* {@link CassandraValueProvider} to read property values from a {@link Row}.
|
||||
*
|
||||
*
|
||||
* @author Alex Shvid
|
||||
* @author Matthew T. Adams
|
||||
* @author David Webb
|
||||
@@ -39,14 +38,14 @@ public class BasicCassandraRowValueProvider implements CassandraRowValueProvider
|
||||
/**
|
||||
* Creates a new {@link BasicCassandraRowValueProvider} with the given {@link Row} and
|
||||
* {@link DefaultSpELExpressionEvaluator}.
|
||||
*
|
||||
*
|
||||
* @param source must not be {@literal null}.
|
||||
* @param evaluator must not be {@literal null}.
|
||||
*/
|
||||
public BasicCassandraRowValueProvider(Row source, DefaultSpELExpressionEvaluator evaluator) {
|
||||
|
||||
Assert.notNull(source);
|
||||
Assert.notNull(evaluator);
|
||||
Assert.notNull(source, "Source Row must not be null");
|
||||
Assert.notNull(evaluator, "DefaultSpELExpressionEvaluator must not be null");
|
||||
|
||||
this.reader = new ColumnReader(source);
|
||||
this.evaluator = evaluator;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 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.
|
||||
@@ -40,7 +40,7 @@ class ConverterRegistration {
|
||||
*/
|
||||
public ConverterRegistration(ConvertiblePair convertiblePair, boolean isReading, boolean isWriting) {
|
||||
|
||||
Assert.notNull(convertiblePair);
|
||||
Assert.notNull(convertiblePair, "ConvertiblePair must not be null");
|
||||
|
||||
this.convertiblePair = convertiblePair;
|
||||
this.reading = isReading;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 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.
|
||||
@@ -83,7 +83,7 @@ public class CustomConversions {
|
||||
*/
|
||||
public CustomConversions(List<?> converters) {
|
||||
|
||||
Assert.notNull(converters);
|
||||
Assert.notNull(converters, "List of converters must not be null");
|
||||
|
||||
this.readingPairs = new LinkedHashSet<ConvertiblePair>();
|
||||
this.writingPairs = new LinkedHashSet<ConvertiblePair>();
|
||||
@@ -249,9 +249,9 @@ public class CustomConversions {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the target type we can inject of the given source type to. The returned type might
|
||||
* be a subclass of the given expected type though. If {@code expectedTargetType} is {@literal null} we will simply
|
||||
* return the first target type matching or {@literal null} if no conversion can be found.
|
||||
* Returns the target type we can inject of the given source type to. The returned type might be a subclass of the
|
||||
* given expected type though. If {@code expectedTargetType} is {@literal null} we will simply return the first target
|
||||
* type matching or {@literal null} if no conversion can be found.
|
||||
*
|
||||
* @param sourceType must not be {@literal null}
|
||||
* @param requestedTargetType
|
||||
@@ -274,8 +274,8 @@ public class CustomConversions {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether we have a custom conversion registered into a Cassandra native type. The
|
||||
* returned type might be a subclass of the given expected type though.
|
||||
* Returns whether we have a custom conversion registered into a Cassandra native type. The returned type might be a
|
||||
* subclass of the given expected type though.
|
||||
*
|
||||
* @param sourceType must not be {@literal null}
|
||||
* @return
|
||||
@@ -285,8 +285,8 @@ public class CustomConversions {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether we have a custom conversion registered to an object of the given source type
|
||||
* into an object of the given Cassandra native target type.
|
||||
* Returns whether we have a custom conversion registered to an object of the given source type into an object of the
|
||||
* given Cassandra native target type.
|
||||
*
|
||||
* @param sourceType must not be {@literal null}.
|
||||
* @param requestedTargetType
|
||||
@@ -297,8 +297,7 @@ public class CustomConversions {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether we have a custom conversion registered to the given source into the given target
|
||||
* type.
|
||||
* Returns whether we have a custom conversion registered to the given source into the given target type.
|
||||
*
|
||||
* @param sourceType must not be {@literal null}
|
||||
* @param requestedTargetType must not be {@literal null}
|
||||
@@ -344,8 +343,8 @@ public class CustomConversions {
|
||||
private static Class<?> getCustomTarget(Class<?> sourceType, Class<?> requestedTargetType,
|
||||
Collection<ConvertiblePair> pairs) {
|
||||
|
||||
Assert.notNull(sourceType);
|
||||
Assert.notNull(pairs);
|
||||
Assert.notNull(sourceType, "Source Class must not be null");
|
||||
Assert.notNull(pairs, "Collection of ConvertiblePair must not be null");
|
||||
|
||||
if (requestedTargetType != null && pairs.contains(new ConvertiblePair(sourceType, requestedTargetType))) {
|
||||
return requestedTargetType;
|
||||
@@ -383,7 +382,7 @@ public class CustomConversions {
|
||||
|
||||
Class<?> type = producer.get();
|
||||
|
||||
cache.put(key, CacheValue.<Class<?>>ofNullable(type));
|
||||
cache.put(key, CacheValue.<Class<?>> ofNullable(type));
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors
|
||||
*
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -24,7 +24,7 @@ import com.datastax.driver.core.Row;
|
||||
/**
|
||||
* Simple {@link RowCallback} that will transform a {@link Row} into the given target type using the given
|
||||
* {@link CassandraConverter}.
|
||||
*
|
||||
*
|
||||
* @author Alex Shvid
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
@@ -35,8 +35,8 @@ public class CassandraConverterRowCallback<T> implements RowCallback<T> {
|
||||
|
||||
public CassandraConverterRowCallback(CassandraConverter reader, Class<T> type) {
|
||||
|
||||
Assert.notNull(reader);
|
||||
Assert.notNull(type);
|
||||
Assert.notNull(reader, "CassandraConverter must not be null");
|
||||
Assert.notNull(type, "Target class must not be null");
|
||||
|
||||
this.reader = reader;
|
||||
this.type = type;
|
||||
|
||||
@@ -20,8 +20,6 @@ import static org.springframework.cassandra.core.cql.CqlIdentifier.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.datastax.driver.core.UserType;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.cassandra.core.cql.CqlIdentifier;
|
||||
import org.springframework.cassandra.support.exception.UnsupportedCassandraOperationException;
|
||||
@@ -40,6 +38,8 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.datastax.driver.core.UserType;
|
||||
|
||||
/**
|
||||
* Cassandra specific {@link BasicPersistentEntity} implementation that adds Cassandra specific metadata.
|
||||
*
|
||||
@@ -51,8 +51,7 @@ import org.springframework.util.StringUtils;
|
||||
public class BasicCassandraPersistentEntity<T> extends BasicPersistentEntity<T, CassandraPersistentProperty>
|
||||
implements CassandraPersistentEntity<T>, ApplicationContextAware {
|
||||
|
||||
protected static final CassandraPersistentEntityMetadataVerifier DEFAULT_VERIFIER =
|
||||
new CompositeCassandraPersistentEntityMetadataVerifier();
|
||||
protected static final CassandraPersistentEntityMetadataVerifier DEFAULT_VERIFIER = new CompositeCassandraPersistentEntityMetadataVerifier();
|
||||
|
||||
protected ApplicationContext context;
|
||||
|
||||
@@ -124,8 +123,8 @@ public class BasicCassandraPersistentEntity<T> extends BasicPersistentEntity<T,
|
||||
|
||||
List<CassandraPersistentProperty> properties = new ArrayList<CassandraPersistentProperty>();
|
||||
|
||||
Assert.state(isCompositePrimaryKey(), String.format("[%s] does not represent a composite primary key class",
|
||||
this.getType().getName()));
|
||||
Assert.state(isCompositePrimaryKey(),
|
||||
String.format("[%s] does not represent a composite primary key class", this.getType().getName()));
|
||||
|
||||
addCompositePrimaryKeyProperties(this, properties);
|
||||
|
||||
@@ -189,7 +188,8 @@ public class BasicCassandraPersistentEntity<T> extends BasicPersistentEntity<T,
|
||||
|
||||
@Override
|
||||
public void setTableName(CqlIdentifier tableName) {
|
||||
Assert.notNull(tableName);
|
||||
|
||||
Assert.notNull(tableName, "CqlIdentifier must not be null");
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.mapping;
|
||||
|
||||
import static org.springframework.cassandra.core.cql.CqlIdentifier.cqlId;
|
||||
import static org.springframework.cassandra.core.cql.CqlIdentifier.*;
|
||||
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.lang.reflect.Field;
|
||||
@@ -122,7 +122,7 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext context) {
|
||||
|
||||
Assert.notNull(context);
|
||||
Assert.notNull(context, "ApplicationContext must not be null");
|
||||
|
||||
this.context = context;
|
||||
spelContext = new StandardEvaluationContext();
|
||||
@@ -297,7 +297,7 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
|
||||
if (dataType == null) {
|
||||
throw new InvalidDataAccessApiUsageException(String.format(
|
||||
"Only primitive types are allowed inside Collections for property [%1$s] of type [%2$s] in entity [%3$s]",
|
||||
getName(), getType(), getOwner().getName()));
|
||||
getName(), getType(), getOwner().getName()));
|
||||
}
|
||||
|
||||
return dataType;
|
||||
@@ -316,7 +316,7 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
|
||||
if (dataType == null) {
|
||||
throw new InvalidDataAccessApiUsageException(String.format(
|
||||
"Only primitive types are allowed inside Collections for property [%1$s] of type ['%2$s'] in entity [%3$s]",
|
||||
getName(), getType(), getOwner().getName()));
|
||||
getName(), getType(), getOwner().getName()));
|
||||
}
|
||||
|
||||
return dataType;
|
||||
@@ -410,18 +410,19 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
|
||||
@Override
|
||||
public void setColumnNames(List<CqlIdentifier> columnNames) {
|
||||
|
||||
Assert.notNull(columnNames);
|
||||
Assert.notNull(columnNames, "List of column names must not be null");
|
||||
|
||||
// force calculation of columnNames if not known yet
|
||||
getColumnNames();
|
||||
|
||||
Assert.state(this.columnNames.size() == columnNames.size(), String.format(
|
||||
"Property [%s] of entity [%s] is mapped to [%s] column%s, but given column name list has size [%s]",
|
||||
getName(), getOwner().getType().getName(), this.columnNames.size(), this.columnNames.size() == 1 ? "" : "s",
|
||||
columnNames.size()));
|
||||
Assert.state(this.columnNames.size() == columnNames.size(),
|
||||
String.format(
|
||||
"Property [%s] of entity [%s] is mapped to [%s] column%s, but given column name list has size [%s]",
|
||||
getName(), getOwner().getType().getName(), this.columnNames.size(), this.columnNames.size() == 1 ? "" : "s",
|
||||
columnNames.size()));
|
||||
|
||||
this.columnNames = this.explicitColumnNames =
|
||||
Collections.unmodifiableList(new ArrayList<CqlIdentifier>(columnNames));
|
||||
this.columnNames = this.explicitColumnNames = Collections
|
||||
.unmodifiableList(new ArrayList<CqlIdentifier>(columnNames));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -65,7 +65,8 @@ public class EntityMapping {
|
||||
}
|
||||
|
||||
public void setEntityClassName(String entityClassName) {
|
||||
Assert.hasText(entityClassName);
|
||||
|
||||
Assert.hasText(entityClassName, "Entity class name must not be null or empty");
|
||||
this.entityClassName = entityClassName;
|
||||
}
|
||||
|
||||
@@ -74,7 +75,8 @@ public class EntityMapping {
|
||||
}
|
||||
|
||||
public void setForceQuote(String forceQuote) {
|
||||
Assert.notNull(forceQuote);
|
||||
|
||||
Assert.notNull(forceQuote, "Force quote must not be null or empty");
|
||||
this.forceQuote = forceQuote;
|
||||
}
|
||||
|
||||
@@ -84,7 +86,7 @@ public class EntityMapping {
|
||||
|
||||
public void setPropertyMappings(Map<String, PropertyMapping> propertyMappings) {
|
||||
this.propertyMappings = (propertyMappings != null ? new HashMap<String, PropertyMapping>(propertyMappings)
|
||||
: Collections.<String, PropertyMapping>emptyMap());
|
||||
: Collections.<String, PropertyMapping> emptyMap());
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
@@ -92,7 +94,8 @@ public class EntityMapping {
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
Assert.notNull(tableName);
|
||||
|
||||
Assert.notNull(tableName, "Table name must not be null or empty");
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
@@ -112,8 +115,8 @@ public class EntityMapping {
|
||||
EntityMapping that = (EntityMapping) obj;
|
||||
|
||||
return ObjectUtils.nullSafeEquals(this.getEntityClassName(), that.getEntityClassName())
|
||||
&& ObjectUtils.nullSafeEquals(this.getForceQuote(), that.getForceQuote())
|
||||
&& ObjectUtils.nullSafeEquals(this.getTableName(), that.getTableName());
|
||||
&& ObjectUtils.nullSafeEquals(this.getForceQuote(), that.getForceQuote())
|
||||
&& ObjectUtils.nullSafeEquals(this.getTableName(), that.getTableName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,9 +137,8 @@ public class EntityMapping {
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
"{ @type = %1$s, entityClassName = %2$s, tableName = %3$s, forceQuote = %4$s, propertyMappings = %5$s }",
|
||||
getClass().getName(), getEntityClassName(), getTableName(), getForceQuote(),
|
||||
toString(getPropertyMappings()));
|
||||
"{ @type = %1$s, entityClassName = %2$s, tableName = %3$s, forceQuote = %4$s, propertyMappings = %5$s }",
|
||||
getClass().getName(), getEntityClassName(), getTableName(), getForceQuote(), toString(getPropertyMappings()));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -49,7 +49,8 @@ public class PropertyMapping {
|
||||
}
|
||||
|
||||
public void setColumnName(String columnName) {
|
||||
Assert.notNull(columnName);
|
||||
|
||||
Assert.notNull(columnName, "Column name must not be null");
|
||||
this.columnName = columnName;
|
||||
}
|
||||
|
||||
@@ -66,7 +67,8 @@ public class PropertyMapping {
|
||||
}
|
||||
|
||||
public void setPropertyName(String propertyName) {
|
||||
Assert.notNull(propertyName);
|
||||
|
||||
Assert.notNull(propertyName, "Property name must not be null");
|
||||
this.propertyName = propertyName;
|
||||
}
|
||||
|
||||
@@ -86,8 +88,8 @@ public class PropertyMapping {
|
||||
PropertyMapping that = (PropertyMapping) obj;
|
||||
|
||||
return ObjectUtils.nullSafeEquals(this.getPropertyName(), that.getPropertyName())
|
||||
&& ObjectUtils.nullSafeEquals(this.getColumnName(), that.getColumnName())
|
||||
&& ObjectUtils.nullSafeEquals(this.getForceQuote(), that.getForceQuote());
|
||||
&& ObjectUtils.nullSafeEquals(this.getColumnName(), that.getColumnName())
|
||||
&& ObjectUtils.nullSafeEquals(this.getForceQuote(), that.getForceQuote());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,6 +110,6 @@ public class PropertyMapping {
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("{ @type = %1$s, propertyName = %2$s, columnName = %3$s, forceQuote = %4$s }",
|
||||
getClass().getName(), getPropertyName(), getColumnName(), getForceQuote());
|
||||
getClass().getName(), getPropertyName(), getColumnName(), getForceQuote());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2017 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.repository.support;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -17,15 +32,16 @@ import org.springframework.util.Assert;
|
||||
* <em>Note:</em> This could be extended in various cool ways, like one that takes a type and validates that the given
|
||||
* name corresponds to an actual field or bean property on that type. There could also be another one that uses a
|
||||
* {@link CassandraPersistentEntity} and {@link CassandraPersistentProperty} instead of a String name.
|
||||
*
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class BasicMapId implements MapId {
|
||||
|
||||
/**
|
||||
* Factory method. Convenient if imported statically.
|
||||
*
|
||||
*
|
||||
* @return {@link BasicMapId}
|
||||
*/
|
||||
public static MapId id() {
|
||||
@@ -34,7 +50,7 @@ public class BasicMapId implements MapId {
|
||||
|
||||
/**
|
||||
* Factory method. Convenient if imported statically.
|
||||
*
|
||||
*
|
||||
* @return {@link BasicMapId}
|
||||
*/
|
||||
public static MapId id(String name, Serializable value) {
|
||||
@@ -43,7 +59,7 @@ public class BasicMapId implements MapId {
|
||||
|
||||
/**
|
||||
* Factory method. Convenient if imported statically.
|
||||
*
|
||||
*
|
||||
* @return {@link BasicMapId}
|
||||
*/
|
||||
public static MapId id(MapId id) {
|
||||
@@ -56,7 +72,7 @@ public class BasicMapId implements MapId {
|
||||
|
||||
public BasicMapId(Map<String, Serializable> map) {
|
||||
|
||||
Assert.notNull(map);
|
||||
Assert.notNull(map, "Map must not be null");
|
||||
this.map.putAll(map);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -62,7 +62,7 @@ public class CassandraRepositoryFactory extends RepositoryFactorySupport {
|
||||
*/
|
||||
public CassandraRepositoryFactory(CassandraOperations operations) {
|
||||
|
||||
Assert.notNull(operations);
|
||||
Assert.notNull(operations, "CassandraOperations must not be null");
|
||||
|
||||
this.operations = operations;
|
||||
this.mappingContext = operations.getConverter().getMappingContext();
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2017 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.repository.support;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -9,9 +24,10 @@ import org.springframework.util.Assert;
|
||||
/**
|
||||
* Factory class for producing implementations of given id interfaces. For restrictions on id interfaces definitions,
|
||||
* see {@link IdInterfaceValidator#validate(Class)}.
|
||||
*
|
||||
*
|
||||
* @see IdInterfaceValidator#validate(Class)
|
||||
* @author Matthew T. Adams
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class MapIdFactory {
|
||||
@@ -20,13 +36,14 @@ public class MapIdFactory {
|
||||
* Produces an implementation of the given id interface type using the type's class loader. For restrictions on id
|
||||
* interfaces definitions, see {@link IdInterfaceValidator#validate(Class)}. Returns an implementation of the given
|
||||
* interface that also implements {@link MapId} and {@link Serializable}, so it can be cast as such if necessary.
|
||||
*
|
||||
*
|
||||
* @param idInterface The type of the id interface.
|
||||
* @return An implementation of the given interface that also implements {@link MapId} and {@link Serializable}.
|
||||
* @see IdInterfaceValidator#validate(Class)
|
||||
*/
|
||||
public static <T> T id(Class<T> idInterface) {
|
||||
Assert.notNull(idInterface);
|
||||
|
||||
Assert.notNull(idInterface, "Interface class must not be null");
|
||||
return id(idInterface, idInterface.getClassLoader());
|
||||
}
|
||||
|
||||
@@ -34,7 +51,7 @@ public class MapIdFactory {
|
||||
* Produces an implementation of the given class loader. For restrictions on id interfaces definitions, see
|
||||
* {@link IdInterfaceValidator#validate(Class)}. Returns an implementation of the given interface that also implements
|
||||
* {@link MapId} and {@link Serializable}, so it can be cast as such if necessary.
|
||||
*
|
||||
*
|
||||
* @param idInterface The type of the id interface.
|
||||
* @return An implementation of the given interface that also implements {@link MapId} and {@link Serializable}.
|
||||
* @see IdInterfaceValidator#validate(Class)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors
|
||||
*
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -30,7 +30,7 @@ import org.springframework.util.Assert;
|
||||
* {@link CassandraEntityInformation} implementation using a {@link CassandraPersistentEntity} instance to lookup the
|
||||
* necessary information. Can be configured with a custom collection to be returned which will trump the one returned by
|
||||
* the {@link CassandraPersistentEntity} if given.
|
||||
*
|
||||
*
|
||||
* @author Alex Shvid
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
@@ -42,7 +42,7 @@ public class MappingCassandraEntityInformation<T, ID extends Serializable> exten
|
||||
|
||||
/**
|
||||
* Creates a new {@link MappingCassandraEntityInformation} for the given {@link CassandraPersistentEntity}.
|
||||
*
|
||||
*
|
||||
* @param entity must not be {@literal null}.
|
||||
*/
|
||||
public MappingCassandraEntityInformation(CassandraPersistentEntity<T> entity, CassandraConverter converter) {
|
||||
@@ -57,7 +57,7 @@ public class MappingCassandraEntityInformation<T, ID extends Serializable> exten
|
||||
@Override
|
||||
public ID getId(T entity) {
|
||||
|
||||
Assert.notNull(entity);
|
||||
Assert.notNull(entity, "Entity must not be null");
|
||||
|
||||
CassandraPersistentProperty idProperty = entityMetadata.getIdProperty();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 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.
|
||||
@@ -58,7 +58,7 @@ public class ReactiveCassandraRepositoryFactory extends ReactiveRepositoryFactor
|
||||
*/
|
||||
public ReactiveCassandraRepositoryFactory(ReactiveCassandraOperations cassandraOperations) {
|
||||
|
||||
Assert.notNull(cassandraOperations);
|
||||
Assert.notNull(cassandraOperations, "ReactiveCassandraOperations must not be null");
|
||||
|
||||
this.operations = cassandraOperations;
|
||||
this.mappingContext = cassandraOperations.getConverter().getMappingContext();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -18,9 +18,6 @@ package org.springframework.data.cassandra.repository.support;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.datastax.driver.core.querybuilder.QueryBuilder;
|
||||
import com.datastax.driver.core.querybuilder.Select;
|
||||
|
||||
import org.springframework.cassandra.core.util.CollectionUtils;
|
||||
import org.springframework.data.cassandra.core.CassandraOperations;
|
||||
import org.springframework.data.cassandra.core.CassandraTemplate;
|
||||
@@ -28,6 +25,9 @@ import org.springframework.data.cassandra.repository.TypedIdCassandraRepository;
|
||||
import org.springframework.data.cassandra.repository.query.CassandraEntityInformation;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.datastax.driver.core.querybuilder.QueryBuilder;
|
||||
import com.datastax.driver.core.querybuilder.Select;
|
||||
|
||||
/**
|
||||
* Repository base implementation for Cassandra.
|
||||
*
|
||||
@@ -49,8 +49,8 @@ public class SimpleCassandraRepository<T, ID extends Serializable> implements Ty
|
||||
*/
|
||||
public SimpleCassandraRepository(CassandraEntityInformation<T, ID> metadata, CassandraOperations operations) {
|
||||
|
||||
Assert.notNull(operations);
|
||||
Assert.notNull(metadata);
|
||||
Assert.notNull(metadata, "CassandraEntityInformation must not be null");
|
||||
Assert.notNull(operations, "CassandraOperations must not be null");
|
||||
|
||||
this.entityInformation = metadata;
|
||||
this.operations = operations;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Comment {
|
||||
}
|
||||
|
||||
public Comment(CommentKey pk) {
|
||||
Assert.notNull(pk);
|
||||
Assert.notNull(pk, "CommentKey must not be null");
|
||||
this.pk = pk;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@ public class DateThing {
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
Assert.notNull(date);
|
||||
|
||||
Assert.notNull(date, "Date must not be null");
|
||||
this.date = new Date(date.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user