DATAMONGO-1719 - Rename blocking fluent entry interfaces from …Operation to Executable… and remove Operation from intermediate interfaces.
Original Pull Request: #487
This commit is contained in:
committed by
Christoph Strobl
parent
a6a0bde6f2
commit
4734a2925c
@@ -21,8 +21,8 @@ import org.openjdk.jmh.annotations.Setup;
|
||||
import org.openjdk.jmh.annotations.TearDown;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.FindOperationWithQuery;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.TerminatingFindOperation;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.FindWithQuery;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.TerminatingFind;
|
||||
import org.springframework.data.mongodb.core.mapping.Field;
|
||||
import org.springframework.data.mongodb.core.query.BasicQuery;
|
||||
import org.springframework.data.mongodb.microbenchmark.AbstractMicrobenchmark;
|
||||
@@ -45,12 +45,12 @@ public class ProjectionsBenchmark extends AbstractMicrobenchmark {
|
||||
|
||||
private Person source;
|
||||
|
||||
private FindOperationWithQuery<Person> asPerson;
|
||||
private FindOperationWithQuery<DtoProjection> asDtoProjection;
|
||||
private FindOperationWithQuery<ClosedProjection> asClosedProjection;
|
||||
private FindOperationWithQuery<OpenProjection> asOpenProjection;
|
||||
private FindWithQuery<Person> asPerson;
|
||||
private FindWithQuery<DtoProjection> asDtoProjection;
|
||||
private FindWithQuery<ClosedProjection> asClosedProjection;
|
||||
private FindWithQuery<OpenProjection> asOpenProjection;
|
||||
|
||||
private TerminatingFindOperation<Person> asPersonWithFieldsRestriction;
|
||||
private TerminatingFind<Person> asPersonWithFieldsRestriction;
|
||||
private Document fields = new Document("firstname", 1);
|
||||
|
||||
@Setup
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.data.util.CloseableIterator;
|
||||
* <code>
|
||||
* aggregateAndReturn(Jedi.class)
|
||||
* .by(newAggregation(Human.class, project("These are not the droids you are looking for")))
|
||||
* .get();
|
||||
* .all();
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
@@ -47,10 +47,10 @@ public interface ExecutableAggregationOperation {
|
||||
* input type for he aggregation.
|
||||
*
|
||||
* @param domainType must not be {@literal null}.
|
||||
* @return new instance of {@link AggregationOperation}.
|
||||
* @return new instance of {@link ExecutableAggregation}.
|
||||
* @throws IllegalArgumentException if domainType is {@literal null}.
|
||||
*/
|
||||
<T> AggregationOperation<T> aggregateAndReturn(Class<T> domainType);
|
||||
<T> ExecutableAggregation<T> aggregateAndReturn(Class<T> domainType);
|
||||
|
||||
/**
|
||||
* Collection override (Optional).
|
||||
@@ -58,17 +58,17 @@ public interface ExecutableAggregationOperation {
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface AggregationOperationWithCollection<T> {
|
||||
interface AggregationWithCollection<T> {
|
||||
|
||||
/**
|
||||
* Explicitly set the name of the collection to perform the query on. <br />
|
||||
* Skip this step to use the default collection derived from the domain type.
|
||||
*
|
||||
* @param collection must not be {@literal null} nor {@literal empty}.
|
||||
* @return new instance of {@link AggregationOperationWithAggregation}.
|
||||
* @return new instance of {@link AggregationWithAggregation}.
|
||||
* @throws IllegalArgumentException if collection is {@literal null}.
|
||||
*/
|
||||
AggregationOperationWithAggregation<T> inCollection(String collection);
|
||||
AggregationWithAggregation<T> inCollection(String collection);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ public interface ExecutableAggregationOperation {
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface TerminatingAggregationOperation<T> {
|
||||
interface TerminatingAggregation<T> {
|
||||
|
||||
/**
|
||||
* Apply pipeline operations as specified and get all matching elements.
|
||||
@@ -102,22 +102,21 @@ public interface ExecutableAggregationOperation {
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface AggregationOperationWithAggregation<T> {
|
||||
interface AggregationWithAggregation<T> {
|
||||
|
||||
/**
|
||||
* Set the aggregation to be used.
|
||||
*
|
||||
* @param aggregation must not be {@literal null}.
|
||||
* @return new instance of {@link TerminatingAggregationOperation}.
|
||||
* @return new instance of {@link TerminatingAggregation}.
|
||||
* @throws IllegalArgumentException if aggregation is {@literal null}.
|
||||
*/
|
||||
TerminatingAggregationOperation<T> by(Aggregation aggregation);
|
||||
TerminatingAggregation<T> by(Aggregation aggregation);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface AggregationOperation<T>
|
||||
extends AggregationOperationWithCollection<T>, AggregationOperationWithAggregation<T> {}
|
||||
interface ExecutableAggregation<T> extends AggregationWithCollection<T>, AggregationWithAggregation<T> {}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.util.StringUtils;
|
||||
* Implementation of {@link ExecutableAggregationOperation} operating directly on {@link MongoTemplate}.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
class ExecutableAggregationOperationSupport implements ExecutableAggregationOperation {
|
||||
@@ -48,11 +49,11 @@ class ExecutableAggregationOperationSupport implements ExecutableAggregationOper
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> AggregationOperation<T> aggregateAndReturn(Class<T> domainType) {
|
||||
public <T> ExecutableAggregation<T> aggregateAndReturn(Class<T> domainType) {
|
||||
|
||||
Assert.notNull(domainType, "DomainType must not be null!");
|
||||
|
||||
return new AggregationOperationSupport<>(template, null, domainType, null);
|
||||
return new ExecutableAggregationSupport<>(template, null, domainType, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,8 +61,8 @@ class ExecutableAggregationOperationSupport implements ExecutableAggregationOper
|
||||
* @since 2.0
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
static class AggregationOperationSupport<T>
|
||||
implements AggregationOperationWithAggregation<T>, AggregationOperation<T>, TerminatingAggregationOperation<T> {
|
||||
static class ExecutableAggregationSupport<T>
|
||||
implements AggregationWithAggregation<T>, ExecutableAggregation<T>, TerminatingAggregation<T> {
|
||||
|
||||
private final MongoTemplate template;
|
||||
private final Aggregation aggregation;
|
||||
@@ -69,19 +70,19 @@ class ExecutableAggregationOperationSupport implements ExecutableAggregationOper
|
||||
private final String collection;
|
||||
|
||||
@Override
|
||||
public AggregationOperationWithAggregation<T> inCollection(String collection) {
|
||||
public AggregationWithAggregation<T> inCollection(String collection) {
|
||||
|
||||
Assert.hasText(collection, "Collection must not be null nor empty!");
|
||||
|
||||
return new AggregationOperationSupport<>(template, aggregation, domainType, collection);
|
||||
return new ExecutableAggregationSupport<>(template, aggregation, domainType, collection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerminatingAggregationOperation<T> by(Aggregation aggregation) {
|
||||
public TerminatingAggregation<T> by(Aggregation aggregation) {
|
||||
|
||||
Assert.notNull(aggregation, "Aggregation must not be null!");
|
||||
|
||||
return new AggregationOperationSupport<>(template, aggregation, domainType, collection);
|
||||
return new ExecutableAggregationSupport<>(template, aggregation, domainType, collection);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -54,10 +54,10 @@ public interface ExecutableFindOperation {
|
||||
* Start creating a find operation for the given {@literal domainType}.
|
||||
*
|
||||
* @param domainType must not be {@literal null}.
|
||||
* @return new instance of {@link FindOperation}.
|
||||
* @return new instance of {@link ExecutableFind}.
|
||||
* @throws IllegalArgumentException if domainType is {@literal null}.
|
||||
*/
|
||||
<T> FindOperation<T> query(Class<T> domainType);
|
||||
<T> ExecutableFind<T> query(Class<T> domainType);
|
||||
|
||||
/**
|
||||
* Trigger find execution by calling one of the terminating methods.
|
||||
@@ -65,7 +65,7 @@ public interface ExecutableFindOperation {
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface TerminatingFindOperation<T> {
|
||||
interface TerminatingFind<T> {
|
||||
|
||||
/**
|
||||
* Get exactly zero or one result.
|
||||
@@ -137,7 +137,7 @@ public interface ExecutableFindOperation {
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface TerminatingFindNearOperation<T> {
|
||||
interface TerminatingFindNear<T> {
|
||||
|
||||
/**
|
||||
* Find all matching elements and return them as {@link org.springframework.data.geo.GeoResult}.
|
||||
@@ -153,25 +153,25 @@ public interface ExecutableFindOperation {
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface FindOperationWithQuery<T> extends TerminatingFindOperation<T> {
|
||||
interface FindWithQuery<T> extends TerminatingFind<T> {
|
||||
|
||||
/**
|
||||
* Set the filter query to be used.
|
||||
*
|
||||
* @param query must not be {@literal null}.
|
||||
* @return new instance of {@link TerminatingFindOperation}.
|
||||
* @return new instance of {@link TerminatingFind}.
|
||||
* @throws IllegalArgumentException if query is {@literal null}.
|
||||
*/
|
||||
TerminatingFindOperation<T> matching(Query query);
|
||||
TerminatingFind<T> matching(Query query);
|
||||
|
||||
/**
|
||||
* Set the filter query for the geoNear execution.
|
||||
*
|
||||
* @param nearQuery must not be {@literal null}.
|
||||
* @return new instance of {@link TerminatingFindNearOperation}.
|
||||
* @return new instance of {@link TerminatingFindNear}.
|
||||
* @throws IllegalArgumentException if nearQuery is {@literal null}.
|
||||
*/
|
||||
TerminatingFindNearOperation<T> near(NearQuery nearQuery);
|
||||
TerminatingFindNear<T> near(NearQuery nearQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,17 +180,17 @@ public interface ExecutableFindOperation {
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface FindOperationWithCollection<T> extends FindOperationWithQuery<T> {
|
||||
interface FindWithCollection<T> extends FindWithQuery<T> {
|
||||
|
||||
/**
|
||||
* Explicitly set the name of the collection to perform the query on. <br />
|
||||
* Skip this step to use the default collection derived from the domain type.
|
||||
*
|
||||
* @param collection must not be {@literal null} nor {@literal empty}.
|
||||
* @return new instance of {@link FindOperationWithProjection}.
|
||||
* @return new instance of {@link FindWithProjection}.
|
||||
* @throws IllegalArgumentException if collection is {@literal null}.
|
||||
*/
|
||||
FindOperationWithProjection<T> inCollection(String collection);
|
||||
FindWithProjection<T> inCollection(String collection);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,7 +199,7 @@ public interface ExecutableFindOperation {
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface FindOperationWithProjection<T> extends FindOperationWithQuery<T> {
|
||||
interface FindWithProjection<T> extends FindWithQuery<T> {
|
||||
|
||||
/**
|
||||
* Define the target type fields should be mapped to. <br />
|
||||
@@ -207,17 +207,17 @@ public interface ExecutableFindOperation {
|
||||
*
|
||||
* @param resultType must not be {@literal null}.
|
||||
* @param <R> result type.
|
||||
* @return new instance of {@link FindOperationWithProjection}.
|
||||
* @return new instance of {@link FindWithProjection}.
|
||||
* @throws IllegalArgumentException if resultType is {@literal null}.
|
||||
*/
|
||||
<R> FindOperationWithQuery<R> as(Class<R> resultType);
|
||||
<R> FindWithQuery<R> as(Class<R> resultType);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link FindOperation} provides methods for constructing lookup operations in a fluent way.
|
||||
* {@link ExecutableFind} provides methods for constructing lookup operations in a fluent way.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface FindOperation<T> extends FindOperationWithCollection<T>, FindOperationWithProjection<T> {}
|
||||
interface ExecutableFind<T> extends FindWithCollection<T>, FindWithProjection<T> {}
|
||||
}
|
||||
|
||||
@@ -61,11 +61,11 @@ class ExecutableFindOperationSupport implements ExecutableFindOperation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> FindOperation<T> query(Class<T> domainType) {
|
||||
public <T> ExecutableFind<T> query(Class<T> domainType) {
|
||||
|
||||
Assert.notNull(domainType, "DomainType must not be null!");
|
||||
|
||||
return new FindOperationSupport<>(template, domainType, domainType, null, ALL_QUERY);
|
||||
return new ExecutableFindSupport<>(template, domainType, domainType, null, ALL_QUERY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,8 +74,8 @@ class ExecutableFindOperationSupport implements ExecutableFindOperation {
|
||||
* @since 2.0
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
static class FindOperationSupport<T> implements FindOperation<T>, FindOperationWithCollection<T>,
|
||||
FindOperationWithProjection<T>, FindOperationWithQuery<T> {
|
||||
static class ExecutableFindSupport<T>
|
||||
implements ExecutableFind<T>, FindWithCollection<T>, FindWithProjection<T>, FindWithQuery<T> {
|
||||
|
||||
private final MongoTemplate template;
|
||||
private final Class<?> domainType;
|
||||
@@ -84,27 +84,27 @@ class ExecutableFindOperationSupport implements ExecutableFindOperation {
|
||||
private final Query query;
|
||||
|
||||
@Override
|
||||
public FindOperationWithProjection<T> inCollection(String collection) {
|
||||
public FindWithProjection<T> inCollection(String collection) {
|
||||
|
||||
Assert.hasText(collection, "Collection name must not be null nor empty!");
|
||||
|
||||
return new FindOperationSupport<>(template, domainType, returnType, collection, query);
|
||||
return new ExecutableFindSupport<>(template, domainType, returnType, collection, query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T1> FindOperationWithQuery<T1> as(Class<T1> returnType) {
|
||||
public <T1> FindWithQuery<T1> as(Class<T1> returnType) {
|
||||
|
||||
Assert.notNull(returnType, "ReturnType must not be null!");
|
||||
|
||||
return new FindOperationSupport<>(template, domainType, returnType, collection, query);
|
||||
return new ExecutableFindSupport<>(template, domainType, returnType, collection, query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerminatingFindOperation<T> matching(Query query) {
|
||||
public TerminatingFind<T> matching(Query query) {
|
||||
|
||||
Assert.notNull(query, "Query must not be null!");
|
||||
|
||||
return new FindOperationSupport<>(template, domainType, returnType, collection, query);
|
||||
return new ExecutableFindSupport<>(template, domainType, returnType, collection, query);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,7 +142,7 @@ class ExecutableFindOperationSupport implements ExecutableFindOperation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerminatingFindNearOperation<T> near(NearQuery nearQuery) {
|
||||
public TerminatingFindNear<T> near(NearQuery nearQuery) {
|
||||
return () -> template.geoNear(nearQuery, domainType, getCollectionName(), returnType);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.mongodb.bulk.BulkWriteResult;
|
||||
* </pre>
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface ExecutableInsertOperation {
|
||||
@@ -45,10 +46,10 @@ public interface ExecutableInsertOperation {
|
||||
* Start creating an insert operation for given {@literal domainType}.
|
||||
*
|
||||
* @param domainType must not be {@literal null}.
|
||||
* @return new instance of {@link InsertOperation}.
|
||||
* @return new instance of {@link ExecutableInsert}.
|
||||
* @throws IllegalArgumentException if domainType is {@literal null}.
|
||||
*/
|
||||
<T> InsertOperation<T> insert(Class<T> domainType);
|
||||
<T> ExecutableInsert<T> insert(Class<T> domainType);
|
||||
|
||||
/**
|
||||
* Trigger insert execution by calling one of the terminating methods.
|
||||
@@ -56,7 +57,7 @@ public interface ExecutableInsertOperation {
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface TerminatingInsertOperation<T> extends TerminatingBulkInsertOperation<T> {
|
||||
interface TerminatingInsert<T> extends TerminatingBulkInsert<T> {
|
||||
|
||||
/**
|
||||
* Insert exactly one object.
|
||||
@@ -81,7 +82,7 @@ public interface ExecutableInsertOperation {
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface TerminatingBulkInsertOperation<T> {
|
||||
interface TerminatingBulkInsert<T> {
|
||||
|
||||
/**
|
||||
* Bulk write collection of objects.
|
||||
@@ -97,41 +98,40 @@ public interface ExecutableInsertOperation {
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface InsertOperation<T>
|
||||
extends TerminatingInsertOperation<T>, InsertOperationWithCollection<T>, InsertOperationWithBulkMode<T> {}
|
||||
interface ExecutableInsert<T> extends TerminatingInsert<T>, InsertWithCollection<T>, InsertWithBulkMode<T> {}
|
||||
|
||||
/**
|
||||
* Collection override (Optional).
|
||||
* Collection override (optional).
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface InsertOperationWithCollection<T> {
|
||||
interface InsertWithCollection<T> {
|
||||
|
||||
/**
|
||||
* Explicitly set the name of the collection. <br />
|
||||
* Skip this step to use the default collection derived from the domain type.
|
||||
*
|
||||
* @param collection must not be {@literal null} nor {@literal empty}.
|
||||
* @return new instance of {@link InsertOperationWithBulkMode}.
|
||||
* @return new instance of {@link InsertWithBulkMode}.
|
||||
* @throws IllegalArgumentException if collection is {@literal null}.
|
||||
*/
|
||||
InsertOperationWithBulkMode<T> inCollection(String collection);
|
||||
InsertWithBulkMode<T> inCollection(String collection);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface InsertOperationWithBulkMode<T> extends TerminatingInsertOperation<T> {
|
||||
interface InsertWithBulkMode<T> extends TerminatingInsert<T> {
|
||||
|
||||
/**
|
||||
* Define the {@link BulkMode} to use for bulk insert operation.
|
||||
*
|
||||
* @param bulkMode must not be {@literal null}.
|
||||
* @return new instance of {@link TerminatingBulkInsertOperation}.
|
||||
* @return new instance of {@link TerminatingBulkInsert}.
|
||||
* @throws IllegalArgumentException if bulkMode is {@literal null}.
|
||||
*/
|
||||
TerminatingBulkInsertOperation<T> withBulkMode(BulkMode bulkMode);
|
||||
TerminatingBulkInsert<T> withBulkMode(BulkMode bulkMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.mongodb.bulk.BulkWriteResult;
|
||||
* Implementation of {@link ExecutableInsertOperation}.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
class ExecutableInsertOperationSupport implements ExecutableInsertOperation {
|
||||
@@ -50,11 +51,11 @@ class ExecutableInsertOperationSupport implements ExecutableInsertOperation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> InsertOperation<T> insert(Class<T> domainType) {
|
||||
public <T> ExecutableInsert<T> insert(Class<T> domainType) {
|
||||
|
||||
Assert.notNull(domainType, "DomainType must not be null!");
|
||||
|
||||
return new InsertOperationSupport<>(template, domainType, null, null);
|
||||
return new ExecutableInsertSupport<>(template, domainType, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,7 +63,7 @@ class ExecutableInsertOperationSupport implements ExecutableInsertOperation {
|
||||
* @since 2.0
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
static class InsertOperationSupport<T> implements InsertOperation<T> {
|
||||
static class ExecutableInsertSupport<T> implements ExecutableInsert<T> {
|
||||
|
||||
private final MongoTemplate template;
|
||||
private final Class<T> domainType;
|
||||
@@ -95,19 +96,19 @@ class ExecutableInsertOperationSupport implements ExecutableInsertOperation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InsertOperationWithBulkMode<T> inCollection(String collection) {
|
||||
public InsertWithBulkMode<T> inCollection(String collection) {
|
||||
|
||||
Assert.hasText(collection, "Collection must not be null nor empty.");
|
||||
|
||||
return new InsertOperationSupport<>(template, domainType, collection, bulkMode);
|
||||
return new ExecutableInsertSupport<>(template, domainType, collection, bulkMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerminatingBulkInsertOperation<T> withBulkMode(BulkMode bulkMode) {
|
||||
public TerminatingBulkInsert<T> withBulkMode(BulkMode bulkMode) {
|
||||
|
||||
Assert.notNull(bulkMode, "BulkMode must not be null!");
|
||||
|
||||
return new InsertOperationSupport<>(template, domainType, collection, bulkMode);
|
||||
return new ExecutableInsertSupport<>(template, domainType, collection, bulkMode);
|
||||
}
|
||||
|
||||
private String getCollectionName() {
|
||||
|
||||
@@ -39,6 +39,7 @@ import com.mongodb.client.result.DeleteResult;
|
||||
* </pre>
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface ExecutableRemoveOperation {
|
||||
@@ -47,36 +48,36 @@ public interface ExecutableRemoveOperation {
|
||||
* Start creating a remove operation for the given {@literal domainType}.
|
||||
*
|
||||
* @param domainType must not be {@literal null}.
|
||||
* @return new instance of {@link RemoveOperation}.
|
||||
* @return new instance of {@link ExecutableRemove}.
|
||||
* @throws IllegalArgumentException if domainType is {@literal null}.
|
||||
*/
|
||||
<T> RemoveOperation<T> remove(Class<T> domainType);
|
||||
<T> ExecutableRemove<T> remove(Class<T> domainType);
|
||||
|
||||
/**
|
||||
* Collection override (Optional).
|
||||
* Collection override (optional).
|
||||
*
|
||||
* @param <T>
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface RemoveOperationWithCollection<T> extends RemoveOperationWithQuery<T> {
|
||||
interface RemoveWithCollection<T> extends RemoveWithQuery<T> {
|
||||
|
||||
/**
|
||||
* Explicitly set the name of the collection to perform the query on. <br />
|
||||
* Skip this step to use the default collection derived from the domain type.
|
||||
*
|
||||
* @param collection must not be {@literal null} nor {@literal empty}.
|
||||
* @return new instance of {@link RemoveOperationWithCollection}.
|
||||
* @return new instance of {@link RemoveWithCollection}.
|
||||
* @throws IllegalArgumentException if collection is {@literal null}.
|
||||
*/
|
||||
RemoveOperationWithQuery<T> inCollection(String collection);
|
||||
RemoveWithQuery<T> inCollection(String collection);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface TerminatingRemoveOperation<T> {
|
||||
interface TerminatingRemove<T> {
|
||||
|
||||
/**
|
||||
* Remove all documents matching.
|
||||
@@ -100,21 +101,21 @@ public interface ExecutableRemoveOperation {
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface RemoveOperationWithQuery<T> extends TerminatingRemoveOperation<T> {
|
||||
interface RemoveWithQuery<T> extends TerminatingRemove<T> {
|
||||
|
||||
/**
|
||||
* Define the query filtering elements.
|
||||
*
|
||||
* @param query must not be {@literal null}.
|
||||
* @return new instance of {@link TerminatingRemoveOperation}.
|
||||
* @return new instance of {@link TerminatingRemove}.
|
||||
* @throws IllegalArgumentException if query is {@literal null}.
|
||||
*/
|
||||
TerminatingRemoveOperation<T> matching(Query query);
|
||||
TerminatingRemove<T> matching(Query query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface RemoveOperation<T> extends RemoveOperationWithCollection<T> {}
|
||||
interface ExecutableRemove<T> extends RemoveWithCollection<T> {}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.mongodb.client.result.DeleteResult;
|
||||
* Implementation of {@link ExecutableRemoveOperation}.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
class ExecutableRemoveOperationSupport implements ExecutableRemoveOperation {
|
||||
@@ -51,11 +52,11 @@ class ExecutableRemoveOperationSupport implements ExecutableRemoveOperation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> RemoveOperation<T> remove(Class<T> domainType) {
|
||||
public <T> ExecutableRemove<T> remove(Class<T> domainType) {
|
||||
|
||||
Assert.notNull(domainType, "DomainType must not be null!");
|
||||
|
||||
return new RemoveOperationSupport<>(tempate, null, domainType, null);
|
||||
return new ExecutableRemoveSupport<>(tempate, null, domainType, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +64,7 @@ class ExecutableRemoveOperationSupport implements ExecutableRemoveOperation {
|
||||
* @since 2.0
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
static class RemoveOperationSupport<T> implements RemoveOperation<T>, RemoveOperationWithCollection<T> {
|
||||
static class ExecutableRemoveSupport<T> implements ExecutableRemove<T>, RemoveWithCollection<T> {
|
||||
|
||||
private final MongoTemplate template;
|
||||
private final Query query;
|
||||
@@ -71,19 +72,19 @@ class ExecutableRemoveOperationSupport implements ExecutableRemoveOperation {
|
||||
private final String collection;
|
||||
|
||||
@Override
|
||||
public RemoveOperationWithQuery<T> inCollection(String collection) {
|
||||
public RemoveWithQuery<T> inCollection(String collection) {
|
||||
|
||||
Assert.hasText(collection, "Collection must not be null nor empty!");
|
||||
|
||||
return new RemoveOperationSupport<>(template, query, domainType, collection);
|
||||
return new ExecutableRemoveSupport<>(template, query, domainType, collection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerminatingRemoveOperation<T> matching(Query query) {
|
||||
public TerminatingRemove<T> matching(Query query) {
|
||||
|
||||
Assert.notNull(query, "Query must not be null!");
|
||||
|
||||
return new RemoveOperationSupport<>(template, query, domainType, collection);
|
||||
return new ExecutableRemoveSupport<>(template, query, domainType, collection);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,6 +42,7 @@ import com.mongodb.client.result.UpdateResult;
|
||||
* </pre>
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface ExecutableUpdateOperation {
|
||||
@@ -50,17 +51,16 @@ public interface ExecutableUpdateOperation {
|
||||
* Start creating an update operation for the given {@literal domainType}.
|
||||
*
|
||||
* @param domainType must not be {@literal null}.
|
||||
* @return new instance of {@link UpdateOperation}.
|
||||
* @return new instance of {@link ExecutableUpdate}.
|
||||
* @throws IllegalArgumentException if domainType is {@literal null}.
|
||||
*/
|
||||
<T> UpdateOperation<T> update(Class<T> domainType);
|
||||
<T> ExecutableUpdate<T> update(Class<T> domainType);
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface UpdateOperation<T>
|
||||
extends UpdateOperationWithCollection<T>, UpdateOperationWithQuery<T>, UpdateOperationWithUpdate<T> {}
|
||||
interface ExecutableUpdate<T> extends UpdateWithCollection<T>, UpdateWithQuery<T>, UpdateWithUpdate<T> {}
|
||||
|
||||
/**
|
||||
* Declare the {@link Update} to apply.
|
||||
@@ -68,16 +68,16 @@ public interface ExecutableUpdateOperation {
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface UpdateOperationWithUpdate<T> {
|
||||
interface UpdateWithUpdate<T> {
|
||||
|
||||
/**
|
||||
* Set the {@link Update} to be applied.
|
||||
*
|
||||
* @param update must not be {@literal null}.
|
||||
* @return new instance of {@link TerminatingUpdateOperation}.
|
||||
* @return new instance of {@link TerminatingUpdate}.
|
||||
* @throws IllegalArgumentException if update is {@literal null}.
|
||||
*/
|
||||
TerminatingUpdateOperation<T> apply(Update update);
|
||||
TerminatingUpdate<T> apply(Update update);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,17 +86,17 @@ public interface ExecutableUpdateOperation {
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface UpdateOperationWithCollection<T> {
|
||||
interface UpdateWithCollection<T> {
|
||||
|
||||
/**
|
||||
* Explicitly set the name of the collection to perform the query on. <br />
|
||||
* Skip this step to use the default collection derived from the domain type.
|
||||
*
|
||||
* @param collection must not be {@literal null} nor {@literal empty}.
|
||||
* @return new instance of {@link UpdateOperationWithCollection}.
|
||||
* @return new instance of {@link UpdateWithCollection}.
|
||||
* @throws IllegalArgumentException if collection is {@literal null}.
|
||||
*/
|
||||
UpdateOperationWithQuery<T> inCollection(String collection);
|
||||
UpdateWithQuery<T> inCollection(String collection);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,16 +105,16 @@ public interface ExecutableUpdateOperation {
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface UpdateOperationWithQuery<T> extends UpdateOperationWithUpdate<T> {
|
||||
interface UpdateWithQuery<T> extends UpdateWithUpdate<T> {
|
||||
|
||||
/**
|
||||
* Filter documents by given {@literal query}.
|
||||
*
|
||||
* @param query must not be {@literal null}.
|
||||
* @return new instance of {@link UpdateOperationWithQuery}.
|
||||
* @return new instance of {@link UpdateWithQuery}.
|
||||
* @throws IllegalArgumentException if query is {@literal null}.
|
||||
*/
|
||||
UpdateOperationWithUpdate<T> matching(Query query);
|
||||
UpdateWithUpdate<T> matching(Query query);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,13 +132,13 @@ public interface ExecutableUpdateOperation {
|
||||
* @return new instance of {@link FindAndModifyWithOptions}.
|
||||
* @throws IllegalArgumentException if options is {@literal null}.
|
||||
*/
|
||||
TerminatingFindAndModifyOperation<T> withOptions(FindAndModifyOptions options);
|
||||
TerminatingFindAndModify<T> withOptions(FindAndModifyOptions options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger findAndModify execution by calling one of the terminating methods.
|
||||
*/
|
||||
interface TerminatingFindAndModifyOperation<T> {
|
||||
interface TerminatingFindAndModify<T> {
|
||||
|
||||
/**
|
||||
* Find, modify and return the first matching document.
|
||||
@@ -154,7 +154,7 @@ public interface ExecutableUpdateOperation {
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
interface TerminatingUpdateOperation<T> extends TerminatingFindAndModifyOperation<T>, FindAndModifyWithOptions<T> {
|
||||
interface TerminatingUpdate<T> extends TerminatingFindAndModify<T>, FindAndModifyWithOptions<T> {
|
||||
|
||||
/**
|
||||
* Update all matching documents in the collection.
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.mongodb.client.result.UpdateResult;
|
||||
* Implementation of {@link ExecutableUpdateOperation}.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
|
||||
@@ -51,11 +52,11 @@ class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> UpdateOperation<T> update(Class<T> domainType) {
|
||||
public <T> ExecutableUpdate<T> update(Class<T> domainType) {
|
||||
|
||||
Assert.notNull(domainType, "DomainType must not be null!");
|
||||
|
||||
return new UpdateOperationSupport<>(template, null, domainType, null, null, null);
|
||||
return new ExecutableUpdateSupport<>(template, null, domainType, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,8 +64,8 @@ class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
|
||||
* @since 2.0
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
static class UpdateOperationSupport<T> implements UpdateOperation<T>, UpdateOperationWithCollection<T>,
|
||||
UpdateOperationWithQuery<T>, TerminatingUpdateOperation<T> {
|
||||
static class ExecutableUpdateSupport<T>
|
||||
implements ExecutableUpdate<T>, UpdateWithCollection<T>, UpdateWithQuery<T>, TerminatingUpdate<T> {
|
||||
|
||||
private final MongoTemplate template;
|
||||
private final Query query;
|
||||
@@ -74,19 +75,19 @@ class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
|
||||
private final FindAndModifyOptions options;
|
||||
|
||||
@Override
|
||||
public TerminatingUpdateOperation<T> apply(Update update) {
|
||||
public TerminatingUpdate<T> apply(Update update) {
|
||||
|
||||
Assert.notNull(update, "Update must not be null!");
|
||||
|
||||
return new UpdateOperationSupport<>(template, query, domainType, update, collection, options);
|
||||
return new ExecutableUpdateSupport<>(template, query, domainType, update, collection, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateOperationWithQuery<T> inCollection(String collection) {
|
||||
public UpdateWithQuery<T> inCollection(String collection) {
|
||||
|
||||
Assert.hasText(collection, "Collection must not be null nor empty!");
|
||||
|
||||
return new UpdateOperationSupport<>(template, query, domainType, update, collection, options);
|
||||
return new ExecutableUpdateSupport<>(template, query, domainType, update, collection, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,11 +110,11 @@ class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateOperationWithUpdate<T> matching(Query query) {
|
||||
public UpdateWithUpdate<T> matching(Query query) {
|
||||
|
||||
Assert.notNull(query, "Query must not be null!");
|
||||
|
||||
return new UpdateOperationSupport<>(template, query, domainType, update, collection, options);
|
||||
return new ExecutableUpdateSupport<>(template, query, domainType, update, collection, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -122,11 +123,11 @@ class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerminatingFindAndModifyOperation<T> withOptions(FindAndModifyOptions options) {
|
||||
public TerminatingFindAndModify<T> withOptions(FindAndModifyOptions options) {
|
||||
|
||||
Assert.notNull(options, "Options must not be null!");
|
||||
|
||||
return new UpdateOperationSupport<>(template, query, domainType, update, collection, options);
|
||||
return new ExecutableUpdateSupport<>(template, query, domainType, update, collection, options);
|
||||
}
|
||||
|
||||
private UpdateResult doUpdate(boolean multi, boolean upsert) {
|
||||
|
||||
@@ -24,19 +24,8 @@ import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bson.Document;
|
||||
@@ -1815,7 +1804,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
* @see org.springframework.data.mongodb.core.ExecutableFindOperation#query(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
public <T> FindOperation<T> query(Class<T> domainType) {
|
||||
public <T> ExecutableFind<T> query(Class<T> domainType) {
|
||||
return new ExecutableFindOperationSupport(this).query(domainType);
|
||||
}
|
||||
|
||||
@@ -1824,7 +1813,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
* @see org.springframework.data.mongodb.core.ExecutableUpdateOperation#update(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
public <T> UpdateOperation<T> update(Class<T> domainType) {
|
||||
public <T> ExecutableUpdate<T> update(Class<T> domainType) {
|
||||
return new ExecutableUpdateOperationSupport(this).update(domainType);
|
||||
}
|
||||
|
||||
@@ -1833,7 +1822,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
* @see org.springframework.data.mongodb.core.ExecutableRemoveOperation#remove(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
public <T> RemoveOperation<T> remove(Class<T> domainType) {
|
||||
public <T> ExecutableRemove<T> remove(Class<T> domainType) {
|
||||
return new ExecutableRemoveOperationSupport(this).remove(domainType);
|
||||
}
|
||||
|
||||
@@ -1842,7 +1831,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
* @see org.springframework.data.mongodb.core.ExecutableAggregationOperation#aggregateAndReturn(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
public <T> AggregationOperation<T> aggregateAndReturn(Class<T> domainType) {
|
||||
public <T> ExecutableAggregation<T> aggregateAndReturn(Class<T> domainType) {
|
||||
return new ExecutableAggregationOperationSupport(this).aggregateAndReturn(domainType);
|
||||
}
|
||||
|
||||
@@ -1851,7 +1840,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
* @see org.springframework.data.mongodb.core.ExecutableInsertOperation#insert(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
public <T> InsertOperation<T> insert(Class<T> domainType) {
|
||||
public <T> ExecutableInsert<T> insert(Class<T> domainType) {
|
||||
return new ExecutableInsertOperationSupport(this).insert(domainType);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2016 the original author or authors.
|
||||
* Copyright 2010-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,8 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.mongodb.repository.query;
|
||||
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.FindOperationWithProjection;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.FindOperationWithQuery;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.FindWithProjection;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.FindWithQuery;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.data.mongodb.repository.query.MongoQueryExecution.DeleteExecution;
|
||||
@@ -42,7 +42,7 @@ public abstract class AbstractMongoQuery implements RepositoryQuery {
|
||||
|
||||
private final MongoQueryMethod method;
|
||||
private final MongoOperations operations;
|
||||
private final FindOperationWithProjection<?> findOperationWithProjection;
|
||||
private final FindWithProjection<?> findOperationWithProjection;
|
||||
|
||||
/**
|
||||
* Creates a new {@link AbstractMongoQuery} from the given {@link MongoQueryMethod} and {@link MongoOperations}.
|
||||
@@ -87,14 +87,14 @@ public abstract class AbstractMongoQuery implements RepositoryQuery {
|
||||
|
||||
ResultProcessor processor = method.getResultProcessor().withDynamicProjection(accessor);
|
||||
ReturnedType returnedType = processor.getReturnedType();
|
||||
FindOperationWithQuery<?> find = findOperationWithProjection.as(returnedType.getTypeToRead());
|
||||
FindWithQuery<?> find = findOperationWithProjection.as(returnedType.getTypeToRead());
|
||||
|
||||
MongoQueryExecution execution = getExecution(accessor, find);
|
||||
|
||||
return processor.processResult(execution.execute(query));
|
||||
}
|
||||
|
||||
private MongoQueryExecution getExecution(ConvertingParameterAccessor accessor, FindOperationWithQuery<?> operation) {
|
||||
private MongoQueryExecution getExecution(ConvertingParameterAccessor accessor, FindWithQuery<?> operation) {
|
||||
|
||||
if (isDeleteQuery()) {
|
||||
return new DeleteExecution(operations, method);
|
||||
|
||||
@@ -30,8 +30,8 @@ import org.springframework.data.geo.GeoPage;
|
||||
import org.springframework.data.geo.GeoResult;
|
||||
import org.springframework.data.geo.GeoResults;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.FindOperationWithQuery;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.TerminatingFindOperation;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.FindWithQuery;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.TerminatingFind;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.query.NearQuery;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
@@ -64,7 +64,7 @@ interface MongoQueryExecution {
|
||||
@RequiredArgsConstructor
|
||||
final class SlicedExecution implements MongoQueryExecution {
|
||||
|
||||
private final @NonNull FindOperationWithQuery<?> find;
|
||||
private final @NonNull FindWithQuery<?> find;
|
||||
private final @NonNull Pageable pageable;
|
||||
|
||||
/*
|
||||
@@ -96,7 +96,7 @@ interface MongoQueryExecution {
|
||||
@RequiredArgsConstructor
|
||||
final class PagedExecution implements MongoQueryExecution {
|
||||
|
||||
private final @NonNull FindOperationWithQuery<?> operation;
|
||||
private final @NonNull FindWithQuery<?> operation;
|
||||
private final @NonNull Pageable pageable;
|
||||
|
||||
/*
|
||||
@@ -108,7 +108,7 @@ interface MongoQueryExecution {
|
||||
|
||||
int overallLimit = query.getLimit();
|
||||
|
||||
TerminatingFindOperation<?> matching = operation.matching(query);
|
||||
TerminatingFind<?> matching = operation.matching(query);
|
||||
|
||||
// Apply raw pagination
|
||||
query.with(pageable);
|
||||
@@ -134,7 +134,7 @@ interface MongoQueryExecution {
|
||||
@RequiredArgsConstructor
|
||||
class GeoNearExecution implements MongoQueryExecution {
|
||||
|
||||
private final @NonNull FindOperationWithQuery<?> operation;
|
||||
private final @NonNull FindWithQuery<?> operation;
|
||||
private final @NonNull MongoQueryMethod method;
|
||||
private final @NonNull MongoParameterAccessor accessor;
|
||||
|
||||
@@ -191,12 +191,12 @@ interface MongoQueryExecution {
|
||||
*/
|
||||
final class PagingGeoNearExecution extends GeoNearExecution {
|
||||
|
||||
private final FindOperationWithQuery<?> operation;
|
||||
private final FindWithQuery<?> operation;
|
||||
private final ConvertingParameterAccessor accessor;
|
||||
private final AbstractMongoQuery mongoQuery;
|
||||
|
||||
PagingGeoNearExecution(FindOperationWithQuery<?> operation, MongoQueryMethod method,
|
||||
ConvertingParameterAccessor accessor, AbstractMongoQuery query) {
|
||||
PagingGeoNearExecution(FindWithQuery<?> operation, MongoQueryMethod method, ConvertingParameterAccessor accessor,
|
||||
AbstractMongoQuery query) {
|
||||
|
||||
super(operation, method, accessor);
|
||||
|
||||
|
||||
@@ -21,16 +21,18 @@ import kotlin.reflect.KClass
|
||||
* Extension for [ExecutableAggregationOperation.aggregateAndReturn] providing a [KClass] based variant.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
fun <T : Any> ExecutableAggregationOperation.aggregateAndReturn(entityClass: KClass<T>): ExecutableAggregationOperation.AggregationOperation<T> =
|
||||
aggregateAndReturn(entityClass.java)
|
||||
fun <T : Any> ExecutableAggregationOperation.aggregateAndReturn(entityClass: KClass<T>): ExecutableAggregationOperation.ExecutableAggregation<T> =
|
||||
aggregateAndReturn(entityClass.java)
|
||||
|
||||
/**
|
||||
* Extension for [ExecutableAggregationOperation.aggregateAndReturn] leveraging reified type parameters.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
inline fun <reified T : Any> ExecutableAggregationOperation.aggregateAndReturn(): ExecutableAggregationOperation.AggregationOperation<T> =
|
||||
aggregateAndReturn(T::class.java)
|
||||
inline fun <reified T : Any> ExecutableAggregationOperation.aggregateAndReturn(): ExecutableAggregationOperation.ExecutableAggregation<T> =
|
||||
aggregateAndReturn(T::class.java)
|
||||
@@ -21,37 +21,41 @@ import kotlin.reflect.KClass
|
||||
* Extension for [ExecutableFindOperation.query] providing a [KClass] based variant.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
fun <T : Any> ExecutableFindOperation.query(entityClass: KClass<T>): ExecutableFindOperation.FindOperation<T> =
|
||||
query(entityClass.java)
|
||||
fun <T : Any> ExecutableFindOperation.query(entityClass: KClass<T>): ExecutableFindOperation.ExecutableFind<T> =
|
||||
query(entityClass.java)
|
||||
|
||||
/**
|
||||
* Extension for [ExecutableFindOperation.query] leveraging reified type parameters.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
inline fun <reified T : Any> ExecutableFindOperation.query(): ExecutableFindOperation.FindOperation<T> =
|
||||
query(T::class.java)
|
||||
inline fun <reified T : Any> ExecutableFindOperation.query(): ExecutableFindOperation.ExecutableFind<T> =
|
||||
query(T::class.java)
|
||||
|
||||
|
||||
/**
|
||||
* Extension for [ExecutableFindOperation.FindOperationWithProjection.as] providing a [KClass] based variant.
|
||||
* Extension for [ExecutableFindOperation.FindWithProjection. as] providing a [KClass] based variant.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
fun <T : Any> ExecutableFindOperation.FindOperationWithProjection<T>.asType(resultType: KClass<T>): ExecutableFindOperation.FindOperationWithQuery<T> =
|
||||
`as`(resultType.java)
|
||||
fun <T : Any> ExecutableFindOperation.FindWithProjection<T>.asType(resultType: KClass<T>): ExecutableFindOperation.FindWithQuery<T> =
|
||||
`as`(resultType.java)
|
||||
|
||||
/**
|
||||
* Extension for [ExecutableFindOperation.FindOperationWithProjection.as] leveraging reified type parameters.
|
||||
* Extension for [ExecutableFindOperation.FindWithProjection. as] leveraging reified type parameters.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
inline fun <reified T : Any> ExecutableFindOperation.FindOperationWithProjection<T>.asType(): ExecutableFindOperation.FindOperationWithQuery<T> =
|
||||
`as`(T::class.java)
|
||||
inline fun <reified T : Any> ExecutableFindOperation.FindWithProjection<T>.asType(): ExecutableFindOperation.FindWithQuery<T> =
|
||||
`as`(T::class.java)
|
||||
|
||||
|
||||
|
||||
@@ -21,16 +21,18 @@ import kotlin.reflect.KClass
|
||||
* Extension for [ExecutableInsertOperation.insert] providing a [KClass] based variant.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
fun <T : Any> ExecutableInsertOperation.insert(entityClass: KClass<T>): ExecutableInsertOperation.InsertOperation<T> =
|
||||
insert(entityClass.java)
|
||||
fun <T : Any> ExecutableInsertOperation.insert(entityClass: KClass<T>): ExecutableInsertOperation.ExecutableInsert<T> =
|
||||
insert(entityClass.java)
|
||||
|
||||
/**
|
||||
* Extension for [ExecutableInsertOperation.insert] leveraging reified type parameters.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
inline fun <reified T : Any> ExecutableInsertOperation.insert(): ExecutableInsertOperation.InsertOperation<T> =
|
||||
insert(T::class.java)
|
||||
inline fun <reified T : Any> ExecutableInsertOperation.insert(): ExecutableInsertOperation.ExecutableInsert<T> =
|
||||
insert(T::class.java)
|
||||
@@ -21,16 +21,18 @@ import kotlin.reflect.KClass
|
||||
* Extension for [ExecutableRemoveOperation.remove] providing a [KClass] based variant.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
fun <T : Any> ExecutableRemoveOperation.remove(entityClass: KClass<T>): ExecutableRemoveOperation.RemoveOperation<T> =
|
||||
remove(entityClass.java)
|
||||
fun <T : Any> ExecutableRemoveOperation.remove(entityClass: KClass<T>): ExecutableRemoveOperation.ExecutableRemove<T> =
|
||||
remove(entityClass.java)
|
||||
|
||||
/**
|
||||
* Extension for [ExecutableRemoveOperation.remove] leveraging reified type parameters.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
inline fun <reified T : Any> ExecutableRemoveOperation.remove(): ExecutableRemoveOperation.RemoveOperation<T> =
|
||||
remove(T::class.java)
|
||||
inline fun <reified T : Any> ExecutableRemoveOperation.remove(): ExecutableRemoveOperation.ExecutableRemove<T> =
|
||||
remove(T::class.java)
|
||||
@@ -31,7 +31,7 @@ import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.geo.GeoResults;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.TerminatingFindOperation;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.TerminatingFind;
|
||||
import org.springframework.data.mongodb.core.index.GeoSpatialIndexType;
|
||||
import org.springframework.data.mongodb.core.index.GeospatialIndex;
|
||||
import org.springframework.data.mongodb.core.mapping.Field;
|
||||
@@ -222,7 +222,7 @@ public class ExecutableFindOperationSupportTests {
|
||||
@Test // DATAMONGO-1733
|
||||
public void streamAllReturningResultsAsClosedInterfaceProjection() {
|
||||
|
||||
TerminatingFindOperation<PersonProjection> operation = template.query(Person.class).as(PersonProjection.class);
|
||||
TerminatingFind<PersonProjection> operation = template.query(Person.class).as(PersonProjection.class);
|
||||
|
||||
assertThat(operation.stream()) //
|
||||
.hasSize(2) //
|
||||
@@ -235,8 +235,7 @@ public class ExecutableFindOperationSupportTests {
|
||||
@Test // DATAMONGO-1733
|
||||
public void streamAllReturningResultsAsOpenInterfaceProjection() {
|
||||
|
||||
TerminatingFindOperation<PersonSpELProjection> operation = template.query(Person.class)
|
||||
.as(PersonSpELProjection.class);
|
||||
TerminatingFind<PersonSpELProjection> operation = template.query(Person.class).as(PersonSpELProjection.class);
|
||||
|
||||
assertThat(operation.stream()) //
|
||||
.hasSize(2) //
|
||||
|
||||
@@ -39,9 +39,9 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.FindOperation;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.FindOperationWithProjection;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.FindOperationWithQuery;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.ExecutableFind;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.FindWithProjection;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.FindWithQuery;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.Person;
|
||||
import org.springframework.data.mongodb.core.convert.DbRefResolver;
|
||||
@@ -71,9 +71,9 @@ import com.mongodb.client.result.DeleteResult;
|
||||
public class AbstractMongoQueryUnitTests {
|
||||
|
||||
@Mock MongoOperations mongoOperationsMock;
|
||||
@Mock FindOperation<?> findOperationMock;
|
||||
@Mock FindOperationWithProjection<?> withProjectionMock;
|
||||
@Mock FindOperationWithQuery<?> withQueryMock;
|
||||
@Mock ExecutableFind<?> findOperationMock;
|
||||
@Mock FindWithProjection<?> withProjectionMock;
|
||||
@Mock FindWithQuery<?> withQueryMock;
|
||||
@Mock BasicMongoPersistentEntity<?> persitentEntityMock;
|
||||
@Mock MongoMappingContext mappingContextMock;
|
||||
@Mock DeleteResult deleteResultMock;
|
||||
|
||||
@@ -35,10 +35,10 @@ import org.springframework.data.geo.GeoResult;
|
||||
import org.springframework.data.geo.GeoResults;
|
||||
import org.springframework.data.geo.Metrics;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.FindOperation;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.FindOperationWithQuery;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.TerminatingFindNearOperation;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.TerminatingFindOperation;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.ExecutableFind;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.FindWithQuery;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.TerminatingFind;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.TerminatingFindNear;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.convert.DbRefResolver;
|
||||
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
|
||||
@@ -66,10 +66,10 @@ import org.springframework.util.ReflectionUtils;
|
||||
public class MongoQueryExecutionUnitTests {
|
||||
|
||||
@Mock MongoOperations mongoOperationsMock;
|
||||
@Mock FindOperation<Object> findOperationMock;
|
||||
@Mock FindOperationWithQuery<Object> operationMock;
|
||||
@Mock TerminatingFindOperation<Object> terminatingMock;
|
||||
@Mock TerminatingFindNearOperation<Object> terminatingGeoMock;
|
||||
@Mock ExecutableFind<Object> findOperationMock;
|
||||
@Mock FindWithQuery<Object> operationMock;
|
||||
@Mock TerminatingFind<Object> terminatingMock;
|
||||
@Mock TerminatingFindNear<Object> terminatingGeoMock;
|
||||
@Mock DbRefResolver dbRefResolver;
|
||||
|
||||
Point POINT = new Point(10, 20);
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.FindOperation;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.ExecutableFind;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.convert.DbRefResolver;
|
||||
import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
|
||||
@@ -65,7 +65,7 @@ import com.mongodb.util.JSONParseException;
|
||||
public class PartTreeMongoQueryUnitTests {
|
||||
|
||||
@Mock MongoOperations mongoOperationsMock;
|
||||
@Mock FindOperation<?> findOperationMock;
|
||||
@Mock ExecutableFind<?> findOperationMock;
|
||||
|
||||
MongoMappingContext mappingContext;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.data.mongodb.core.DocumentTestUtils;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.FindOperation;
|
||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.ExecutableFind;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.convert.DbRefResolver;
|
||||
import org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper;
|
||||
@@ -70,7 +70,7 @@ public class StringBasedMongoQueryUnitTests {
|
||||
SpelExpressionParser PARSER = new SpelExpressionParser();
|
||||
|
||||
@Mock MongoOperations operations;
|
||||
@Mock FindOperation<Object> findOperation;
|
||||
@Mock ExecutableFind<Object> findOperation;
|
||||
@Mock DbRefResolver factory;
|
||||
|
||||
MongoConverter converter;
|
||||
|
||||
Reference in New Issue
Block a user