DATACASS-484 - Prepare Java-based types for Kotlin extensions.

Introduce static empty Query and Update objects.

Remove unused type argument from ReactiveUpdateOperation.
This commit is contained in:
Mark Paluch
2018-03-28 14:51:43 +02:00
committed by John Blum
parent 05a5b4aa28
commit 57a6faeab6
5 changed files with 26 additions and 24 deletions

View File

@@ -556,7 +556,7 @@ public class ReactiveCassandraTemplate implements ReactiveCassandraOperations, A
* @see org.springframework.data.cassandra.core.ReactiveUpdateOperation#update(java.lang.Class)
*/
@Override
public <T> ReactiveUpdate<T> update(Class<T> domainType) {
public ReactiveUpdate update(Class<?> domainType) {
return new ReactiveUpdateOperationSupport(this).update(domainType);
}

View File

@@ -60,12 +60,12 @@ public interface ReactiveUpdateOperation {
* @throws IllegalArgumentException if {@link Class domainType} is {@literal null}.
* @see ReactiveUpdate
*/
<T> ReactiveUpdate<T> update(Class<T> domainType);
ReactiveUpdate update(Class<?> domainType);
/**
* Table override (optional).
*/
interface UpdateWithTable<T> {
interface UpdateWithTable {
/**
* Explicitly set the {@link String name} of the table on which to perform the update.
@@ -78,7 +78,7 @@ public interface ReactiveUpdateOperation {
* @see #inTable(CqlIdentifier)
* @see UpdateWithQuery
*/
default UpdateWithQuery<T> inTable(String table) {
default UpdateWithQuery inTable(String table) {
Assert.hasText(table, "Table name must not be null or empty");
@@ -96,14 +96,14 @@ public interface ReactiveUpdateOperation {
* @see org.springframework.data.cassandra.core.cql.CqlIdentifier
* @see UpdateWithQuery
*/
UpdateWithQuery<T> inTable(CqlIdentifier table);
UpdateWithQuery inTable(CqlIdentifier table);
}
/**
* Define a {@link Query} used as the filter for the {@link Update}.
*/
interface UpdateWithQuery<T> {
interface UpdateWithQuery {
/**
* Filter rows to update by the given {@link Query}.
@@ -114,14 +114,14 @@ public interface ReactiveUpdateOperation {
* @see org.springframework.data.cassandra.core.query.Query
* @see TerminatingUpdate
*/
TerminatingUpdate<T> matching(Query query);
TerminatingUpdate matching(Query query);
}
/**
* Trigger {@code UPDATE} execution by calling one of the terminating methods.
*/
interface TerminatingUpdate<T> {
interface TerminatingUpdate {
/**
* Update all matching rows in the table.
@@ -132,13 +132,12 @@ public interface ReactiveUpdateOperation {
* @see reactor.core.publisher.Mono
*/
Mono<WriteResult> apply(Update update);
}
/**
* The {@link ReactiveUpdate} interface provides methods for constructing {@code UPDATE} operations
* in a fluent way.
*/
interface ReactiveUpdate<T> extends UpdateWithTable<T>, UpdateWithQuery<T> {}
interface ReactiveUpdate extends UpdateWithTable, UpdateWithQuery {}
}

View File

@@ -46,20 +46,20 @@ class ReactiveUpdateOperationSupport implements ReactiveUpdateOperation {
* @see org.springframework.data.cassandra.core.ReactiveUpdateOperation#update(java.lang.Class)
*/
@Override
public <T> ReactiveUpdate<T> update(Class<T> domainType) {
public ReactiveUpdate update(Class<?> domainType) {
Assert.notNull(domainType, "DomainType must not be null");
return new ReactiveUpdateSupport<>(this.template, domainType, Query.empty(), null);
return new ReactiveUpdateSupport(this.template, domainType, Query.empty(), null);
}
@RequiredArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
static class ReactiveUpdateSupport<T> implements ReactiveUpdate<T>, TerminatingUpdate<T> {
static class ReactiveUpdateSupport implements ReactiveUpdate, TerminatingUpdate {
@NonNull ReactiveCassandraTemplate template;
@NonNull Class<T> domainType;
@NonNull Class<?> domainType;
@NonNull Query query;
@@ -69,22 +69,22 @@ class ReactiveUpdateOperationSupport implements ReactiveUpdateOperation {
* @see org.springframework.data.cassandra.core.ReactiveUpdateOperation.UpdateWithTable#inTable(org.springframework.data.cassandra.core.cql.CqlIdentifier)
*/
@Override
public UpdateWithQuery<T> inTable(CqlIdentifier tableName) {
public UpdateWithQuery inTable(CqlIdentifier tableName) {
Assert.notNull(tableName, "Table name must not be null");
return new ReactiveUpdateSupport<>(this.template, this.domainType, this.query, tableName);
return new ReactiveUpdateSupport(this.template, this.domainType, this.query, tableName);
}
/* (non-Javadoc)
* @see org.springframework.data.cassandra.core.ReactiveUpdateOperation.UpdateWithQuery#matching(org.springframework.data.cassandra.core.query.Query)
*/
@Override
public TerminatingUpdate<T> matching(Query query) {
public TerminatingUpdate matching(Query query) {
Assert.notNull(query, "Query must not be null");
return new ReactiveUpdateSupport<>(this.template, this.domainType, query, this.tableName);
return new ReactiveUpdateSupport(this.template, this.domainType, query, this.tableName);
}
/* (non-Javadoc)

View File

@@ -15,9 +15,8 @@
*/
package org.springframework.data.cassandra.core.query;
import static java.util.stream.StreamSupport.stream;
import static org.springframework.util.ObjectUtils.nullSafeEquals;
import static org.springframework.util.ObjectUtils.nullSafeHashCode;
import static java.util.stream.StreamSupport.*;
import static org.springframework.util.ObjectUtils.*;
import java.util.ArrayList;
import java.util.Arrays;
@@ -46,6 +45,9 @@ import com.datastax.driver.core.PagingState;
*/
public class Query implements Filter {
private static final Query EMPTY = new Query(Collections.emptyList(), Columns.empty(), Sort.unsorted(),
Optional.empty(), Optional.empty(), Optional.empty(), false);
private final boolean allowFiltering;
private final Columns columns;
@@ -79,8 +81,7 @@ public class Query implements Filter {
* @return the new {@link Query}.
*/
public static Query empty() {
return new Query(Collections.emptyList(), Columns.empty(), Sort.unsorted(), Optional.empty(), Optional.empty(),
Optional.empty(), false);
return EMPTY;
}
/**

View File

@@ -41,6 +41,8 @@ import org.springframework.util.StringUtils;
*/
public class Update {
private static final Update EMPTY = new Update(Collections.emptyMap());
private final Map<ColumnName, AssignmentOp> updateOperations;
private Update(Map<ColumnName, AssignmentOp> updateOperations) {
@@ -53,7 +55,7 @@ public class Update {
* @return a new {@link Update}.
*/
public static Update empty() {
return new Update(Collections.emptyMap());
return EMPTY;
}
/**