Polishing.

Fix generics. Update since tags. Add GH ticket references.
Use literal null instead of code null in javadoc.

Original Pull Request: #4949
This commit is contained in:
Mark Paluch
2025-05-08 09:06:49 +02:00
parent ec49c14bb9
commit 51d64c3768
22 changed files with 77 additions and 132 deletions

View File

@@ -89,7 +89,7 @@ public interface ExecutableAggregationOperation {
* @param converter the converter, must not be {@literal null}.
* @return new instance of {@link TerminatingAggregation}.
* @throws IllegalArgumentException if {@link QueryResultConverter converter} is {@literal null}.
* @since x.y
* @since 5.0
*/
@Contract("_ -> new")
<R> TerminatingAggregation<R> map(QueryResultConverter<? super T, ? extends R> converter);

View File

@@ -84,7 +84,7 @@ public interface ExecutableFindOperation {
*
* @author Christoph Strobl
* @author Mark Paluch
* @since x.y
* @since 5.0
*/
interface TerminatingResults<T> {
@@ -95,7 +95,7 @@ public interface ExecutableFindOperation {
* @param converter the converter, must not be {@literal null}.
* @return new instance of {@link TerminatingResults}.
* @throws IllegalArgumentException if {@link QueryResultConverter converter} is {@literal null}.
* @since x.y
* @since 5.0
*/
@Contract("_ -> new")
<R> TerminatingResults<R> map(QueryResultConverter<? super T, ? extends R> converter);
@@ -157,7 +157,7 @@ public interface ExecutableFindOperation {
* <p>
* When using {@link KeysetScrollPosition}, make sure to use non-nullable
* {@link org.springframework.data.domain.Sort sort properties} as MongoDB does not support criteria to reconstruct
* a query result from absent document fields or {@code null} values through {@code $gt/$lt} operators.
* a query result from absent document fields or {@literal null} values through {@code $gt/$lt} operators.
*
* @param scrollPosition the scroll position.
* @return a window of the resulting elements.
@@ -173,7 +173,7 @@ public interface ExecutableFindOperation {
* Trigger find execution by calling one of the terminating methods.
*
* @author Christoph Strobl
* @since x.y
* @since 5.0
*/
interface TerminatingProjection {
@@ -214,7 +214,7 @@ public interface ExecutableFindOperation {
* @param converter the converter, must not be {@literal null}.
* @return new instance of {@link TerminatingFindNear}.
* @throws IllegalArgumentException if {@link QueryResultConverter converter} is {@literal null}.
* @since x.y
* @since 5.0
*/
@Contract("_ -> new")
<R> TerminatingFindNear<R> map(QueryResultConverter<? super T, ? extends R> converter);

View File

@@ -64,7 +64,7 @@ public interface ExecutableRemoveOperation {
* @param converter the converter, must not be {@literal null}.
* @return new instance of {@link ExecutableFindOperation.TerminatingResults}.
* @throws IllegalArgumentException if {@link QueryResultConverter converter} is {@literal null}.
* @since x.y
* @since 5.0
*/
@Contract("_ -> new")
<R> TerminatingResults<R> map(QueryResultConverter<? super T, ? extends R> converter);

View File

@@ -18,15 +18,15 @@ package org.springframework.data.mongodb.core;
import java.util.Optional;
import org.jspecify.annotations.Nullable;
import org.springframework.data.mongodb.core.ExecutableFindOperation.TerminatingResults;
import org.springframework.data.mongodb.core.aggregation.AggregationUpdate;
import org.springframework.data.mongodb.core.query.CriteriaDefinition;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.data.mongodb.core.query.UpdateDefinition;
import org.springframework.lang.Contract;
import com.mongodb.client.result.UpdateResult;
import org.springframework.lang.Contract;
/**
* {@link ExecutableUpdateOperation} allows creation and execution of MongoDB update / findAndModify / findAndReplace
@@ -71,7 +71,6 @@ public interface ExecutableUpdateOperation {
*/
interface TerminatingFindAndModify<T> {
/**
* Map the query result to a different type using {@link QueryResultConverter}.
*
@@ -79,7 +78,7 @@ public interface ExecutableUpdateOperation {
* @param converter the converter, must not be {@literal null}.
* @return new instance of {@link TerminatingFindAndModify}.
* @throws IllegalArgumentException if {@link QueryResultConverter converter} is {@literal null}.
* @since x.y
* @since 5.0
*/
@Contract("_ -> new")
<R> TerminatingFindAndModify<R> map(QueryResultConverter<? super T, ? extends R> converter);
@@ -153,10 +152,11 @@ public interface ExecutableUpdateOperation {
* @param converter the converter, must not be {@literal null}.
* @return new instance of {@link TerminatingFindAndModify}.
* @throws IllegalArgumentException if {@link QueryResultConverter converter} is {@literal null}.
* @since x.y
* @since 5.0
*/
@Contract("_ -> new")
<R> TerminatingFindAndReplace<R> mapResult(QueryResultConverter<? super T, ? extends R> converter);
<R> TerminatingFindAndReplace<R> map(QueryResultConverter<? super T, ? extends R> converter);
}
/**

View File

@@ -185,16 +185,9 @@ class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
}
@Override
public <R> TerminatingFindAndModify<R> map(QueryResultConverter<? super T, ? extends R> converter) {
public <R> ExecutableUpdateSupport<S, R> map(QueryResultConverter<? super T, ? extends R> converter) {
return new ExecutableUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions,
findAndReplaceOptions, replacement, targetType, this.resultConverter.andThen(converter));
}
@Override
public <R> TerminatingFindAndReplace<R> mapResult(QueryResultConverter<? super T, ? extends R> converter) {
return new ExecutableUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions,
findAndReplaceOptions, replacement, targetType, this.resultConverter.andThen(converter));
findAndReplaceOptions, replacement, targetType, this.resultConverter.andThen(converter));
}
@Override

View File

@@ -822,7 +822,7 @@ public interface MongoOperations extends FluentMongoOperations {
* <p>
* When using {@link KeysetScrollPosition}, make sure to use non-nullable {@link org.springframework.data.domain.Sort
* sort properties} as MongoDB does not support criteria to reconstruct a query result from absent document fields or
* {@code null} values through {@code $gt/$lt} operators.
* {@literal null} values through {@code $gt/$lt} operators.
*
* @param query the query class that specifies the criteria used to find a document and also an optional fields
* specification. Must not be {@literal null}.
@@ -847,7 +847,7 @@ public interface MongoOperations extends FluentMongoOperations {
* <p>
* When using {@link KeysetScrollPosition}, make sure to use non-nullable {@link org.springframework.data.domain.Sort
* sort properties} as MongoDB does not support criteria to reconstruct a query result from absent document fields or
* {@code null} values through {@code $gt/$lt} operators.
* {@literal null} values through {@code $gt/$lt} operators.
*
* @param query the query class that specifies the criteria used to find a document and also an optional fields
* specification. Must not be {@literal null}.

View File

@@ -15,22 +15,12 @@
*/
package org.springframework.data.mongodb.core;
import static org.springframework.data.mongodb.core.query.SerializationUtils.serializeToJsonSafely;
import static org.springframework.data.mongodb.core.query.SerializationUtils.*;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Scanner;
import java.util.Set;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.BiPredicate;
import java.util.stream.Collectors;
@@ -40,8 +30,8 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@@ -106,18 +96,7 @@ import org.springframework.data.mongodb.core.index.SearchIndexOperationsProvider
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
import org.springframework.data.mongodb.core.mapping.event.AfterConvertCallback;
import org.springframework.data.mongodb.core.mapping.event.AfterConvertEvent;
import org.springframework.data.mongodb.core.mapping.event.AfterDeleteEvent;
import org.springframework.data.mongodb.core.mapping.event.AfterLoadEvent;
import org.springframework.data.mongodb.core.mapping.event.AfterSaveCallback;
import org.springframework.data.mongodb.core.mapping.event.AfterSaveEvent;
import org.springframework.data.mongodb.core.mapping.event.BeforeConvertCallback;
import org.springframework.data.mongodb.core.mapping.event.BeforeConvertEvent;
import org.springframework.data.mongodb.core.mapping.event.BeforeDeleteEvent;
import org.springframework.data.mongodb.core.mapping.event.BeforeSaveCallback;
import org.springframework.data.mongodb.core.mapping.event.BeforeSaveEvent;
import org.springframework.data.mongodb.core.mapping.event.MongoMappingEvent;
import org.springframework.data.mongodb.core.mapping.event.*;
import org.springframework.data.mongodb.core.mapreduce.MapReduceOptions;
import org.springframework.data.mongodb.core.mapreduce.MapReduceResults;
import org.springframework.data.mongodb.core.query.BasicQuery;
@@ -157,21 +136,7 @@ import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoCursor;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.MongoIterable;
import com.mongodb.client.model.CountOptions;
import com.mongodb.client.model.CreateCollectionOptions;
import com.mongodb.client.model.CreateViewOptions;
import com.mongodb.client.model.DeleteOptions;
import com.mongodb.client.model.EstimatedDocumentCountOptions;
import com.mongodb.client.model.FindOneAndDeleteOptions;
import com.mongodb.client.model.FindOneAndReplaceOptions;
import com.mongodb.client.model.FindOneAndUpdateOptions;
import com.mongodb.client.model.ReturnDocument;
import com.mongodb.client.model.TimeSeriesGranularity;
import com.mongodb.client.model.TimeSeriesOptions;
import com.mongodb.client.model.UpdateOptions;
import com.mongodb.client.model.ValidationAction;
import com.mongodb.client.model.ValidationLevel;
import com.mongodb.client.model.ValidationOptions;
import com.mongodb.client.model.*;
import com.mongodb.client.result.DeleteResult;
import com.mongodb.client.result.UpdateResult;
@@ -1148,7 +1113,6 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
return findAndModify(query, update, options, entityClass, collectionName, QueryResultConverter.entity());
}
<S, T> T findAndModify(Query query, UpdateDefinition update, FindAndModifyOptions options,
Class<S> entityClass, String collectionName, QueryResultConverter<? super S, ? extends T> resultConverter) {
@@ -1179,7 +1143,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
return findAndReplace(query, replacement, options, entityType, collectionName, resultType, QueryResultConverter.entity());
}
public <S, T, R> @Nullable R findAndReplace(Query query, S replacement, FindAndReplaceOptions options,
<S, T, R> @Nullable R findAndReplace(Query query, S replacement, FindAndReplaceOptions options,
Class<S> entityType, String collectionName, Class<T> resultType, QueryResultConverter<? super T, ? extends R> resultConverter) {
Assert.notNull(query, "Query must not be null");
@@ -1207,7 +1171,6 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
maybeEmitEvent(new BeforeSaveEvent<>(replacement, mappedReplacement, collectionName));
maybeCallBeforeSave(replacement, mappedReplacement, collectionName);
R saved = doFindAndReplace(collectionPreparer, collectionName, mappedQuery, mappedFields, mappedSort,
queryContext.getCollation(entityType).orElse(null), entityType, mappedReplacement, options, projection, resultConverter);
@@ -2203,25 +2166,15 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
return doFindAndDelete(collectionName, query, entityClass, QueryResultConverter.entity());
}
protected <S,T> List<T> doFindAndDelete(String collectionName, Query query, Class<S> entityClass, QueryResultConverter<? super S, ? extends T> resultConverter) {
<S, T> List<T> doFindAndDelete(String collectionName, Query query, Class<S> entityClass,
QueryResultConverter<? super S, ? extends T> resultConverter) {
List<Object> ids = new ArrayList<>();
// QueryResultConverter<S,T> tmpConverter = new QueryResultConverter<S, S>() {
// @Override
// public S mapDocument(Document document, ConversionResultSupplier<S> reader) {
// ids.add(document.get("_id"));
// return reader.get();
// }
// }.andThen(resultConverter);
// DocumentCallback<T> callback = getResultReader(EntityProjection.nonProjecting(entityClass), collectionName, tmpConverter);
QueryResultConverterCallback callback = new QueryResultConverterCallback(resultConverter, new ProjectingReadCallback<S,S>(getConverter(), EntityProjection.nonProjecting(entityClass), collectionName)) {
QueryResultConverterCallback<S, T> callback = new QueryResultConverterCallback<>(resultConverter,
new ProjectingReadCallback<>(getConverter(), EntityProjection.nonProjecting(entityClass), collectionName)) {
@Override
public Object doWith(Document object) {
public T doWith(Document object) {
ids.add(object.get("_id"));
return super.doWith(object);
}
@@ -2366,7 +2319,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
}
@SuppressWarnings({ "ConstantConditions", "NullAway" })
protected <T, O> Stream<O> doAggregateStream(Aggregation aggregation, String collectionName, Class<T> outputType,
<T, O> Stream<O> doAggregateStream(Aggregation aggregation, String collectionName, Class<T> outputType,
QueryResultConverter<? super T, ? extends O> resultConverter,
@Nullable AggregationOperationContext context) {
@@ -2412,7 +2365,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
cursor = cursor.maxTime(options.getMaxTime().toMillis(), TimeUnit.MILLISECONDS);
}
Class<?> domainType = aggregation instanceof TypedAggregation typedAggregation ? typedAggregation.getInputType()
Class<?> domainType = aggregation instanceof TypedAggregation<?> typedAggregation
? typedAggregation.getInputType()
: null;
Optionals.firstNonEmpty(options::getCollation, //
@@ -2863,7 +2817,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
}
@SuppressWarnings("ConstantConditions")
protected <S, T> @Nullable T doFindAndModify(CollectionPreparer collectionPreparer, String collectionName,
<S, T> @Nullable T doFindAndModify(CollectionPreparer<MongoCollection<Document>> collectionPreparer,
String collectionName,
Document query, @Nullable Document fields, @Nullable Document sort, Class<S> entityClass, UpdateDefinition update,
@Nullable FindAndModifyOptions options, QueryResultConverter<? super S, ? extends T> resultConverter) {
@@ -2911,7 +2866,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
* {@literal false} and {@link FindAndReplaceOptions#isUpsert() upsert} is {@literal false}.
*/
@Nullable
protected <S, T> T doFindAndReplace(CollectionPreparer collectionPreparer, String collectionName,
protected <S, T> T doFindAndReplace(CollectionPreparer<MongoCollection<Document>> collectionPreparer,
String collectionName,
Document mappedQuery, Document mappedFields, Document mappedSort,
com.mongodb.client.model.@Nullable Collation collation, Class<S> entityType, Document replacement,
FindAndReplaceOptions options, Class<T> resultType) {
@@ -2954,7 +2910,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
* @since 3.4
*/
@Nullable
private <S, T, R> R doFindAndReplace(CollectionPreparer collectionPreparer, String collectionName,
private <S, T, R> R doFindAndReplace(CollectionPreparer<MongoCollection<Document>> collectionPreparer,
String collectionName,
Document mappedQuery, Document mappedFields, Document mappedSort,
com.mongodb.client.model.@Nullable Collation collation, Class<T> entityType, Document replacement,
FindAndReplaceOptions options, EntityProjection<S, T> projection, QueryResultConverter<? super S, ? extends R> resultConverter) {

View File

@@ -28,7 +28,7 @@ import org.bson.Document;
* @param <T> object type accepted by this converter.
* @param <R> the returned result type.
* @author Mark Paluch
* @since x.x
* @since 5.0
*/
@FunctionalInterface
public interface QueryResultConverter<T, R> {

View File

@@ -81,7 +81,7 @@ public interface ReactiveAggregationOperation {
* @param converter the converter, must not be {@literal null}.
* @return new instance of {@link ExecutableFindOperation.TerminatingFindNear}.
* @throws IllegalArgumentException if {@link QueryResultConverter converter} is {@literal null}.
* @since x.y
* @since 5.0
*/
@Contract("_ -> new")
<R> TerminatingAggregationOperation<R> map(QueryResultConverter<? super T, ? extends R> converter);

View File

@@ -74,7 +74,7 @@ public interface ReactiveFindOperation {
/**
* Compose find execution by calling one of the terminating methods.
*
* @since x.y
* @since 5.0
*/
interface TerminatingResults<T> {
@@ -85,7 +85,7 @@ public interface ReactiveFindOperation {
* @param converter the converter, must not be {@literal null}.
* @return new instance of {@link TerminatingResults}.
* @throws IllegalArgumentException if {@link QueryResultConverter converter} is {@literal null}.
* @since x.y
* @since 5.0
*/
@Contract("_ -> new")
<R> TerminatingResults<R> map(QueryResultConverter<? super T, ? extends R> converter);
@@ -117,7 +117,7 @@ public interface ReactiveFindOperation {
* <p>
* When using {@link KeysetScrollPosition}, make sure to use non-nullable
* {@link org.springframework.data.domain.Sort sort properties} as MongoDB does not support criteria to reconstruct
* a query result from absent document fields or {@code null} values through {@code $gt/$lt} operators.
* a query result from absent document fields or {@literal null} values through {@code $gt/$lt} operators.
*
* @param scrollPosition the scroll position.
* @return a scroll of the resulting elements.
@@ -147,7 +147,7 @@ public interface ReactiveFindOperation {
/**
* Compose find execution by calling one of the terminating methods.
*
* @since x.y
* @since 5.0
*/
interface TerminatingProjection {
@@ -183,7 +183,7 @@ public interface ReactiveFindOperation {
* @param converter the converter, must not be {@literal null}.
* @return new instance of {@link ExecutableFindOperation.TerminatingFindNear}.
* @throws IllegalArgumentException if {@link QueryResultConverter converter} is {@literal null}.
* @since x.y
* @since 5.0
*/
@Contract("_ -> new")
<R> TerminatingFindNear<R> map(QueryResultConverter<? super T, ? extends R> converter);

View File

@@ -513,7 +513,7 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
* <p>
* When using {@link KeysetScrollPosition}, make sure to use non-nullable {@link org.springframework.data.domain.Sort
* sort properties} as MongoDB does not support criteria to reconstruct a query result from absent document fields or
* {@code null} values through {@code $gt/$lt} operators.
* {@literal null} values through {@code $gt/$lt} operators.
*
* @param query the query class that specifies the criteria used to find a document and also an optional fields
* specification. Must not be {@literal null}.
@@ -538,7 +538,7 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
* <p>
* When using {@link KeysetScrollPosition}, make sure to use non-nullable {@link org.springframework.data.domain.Sort
* sort properties} as MongoDB does not support criteria to reconstruct a query result from absent document fields or
* {@code null} values through {@code $gt/$lt} operators.
* {@literal null} values through {@code $gt/$lt} operators.
*
* @param query the query class that specifies the criteria used to find a document and also an optional fields
* specification. Must not be {@literal null}.

View File

@@ -15,7 +15,7 @@
*/
package org.springframework.data.mongodb.core;
import static org.springframework.data.mongodb.core.query.SerializationUtils.serializeToJsonSafely;
import static org.springframework.data.mongodb.core.query.SerializationUtils.*;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -47,6 +47,7 @@ import org.bson.types.ObjectId;
import org.jspecify.annotations.Nullable;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@@ -109,18 +110,7 @@ import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
import org.springframework.data.mongodb.core.mapping.MongoSimpleTypes;
import org.springframework.data.mongodb.core.mapping.event.AfterConvertEvent;
import org.springframework.data.mongodb.core.mapping.event.AfterDeleteEvent;
import org.springframework.data.mongodb.core.mapping.event.AfterLoadEvent;
import org.springframework.data.mongodb.core.mapping.event.AfterSaveEvent;
import org.springframework.data.mongodb.core.mapping.event.BeforeConvertEvent;
import org.springframework.data.mongodb.core.mapping.event.BeforeDeleteEvent;
import org.springframework.data.mongodb.core.mapping.event.BeforeSaveEvent;
import org.springframework.data.mongodb.core.mapping.event.MongoMappingEvent;
import org.springframework.data.mongodb.core.mapping.event.ReactiveAfterConvertCallback;
import org.springframework.data.mongodb.core.mapping.event.ReactiveAfterSaveCallback;
import org.springframework.data.mongodb.core.mapping.event.ReactiveBeforeConvertCallback;
import org.springframework.data.mongodb.core.mapping.event.ReactiveBeforeSaveCallback;
import org.springframework.data.mongodb.core.mapping.event.*;
import org.springframework.data.mongodb.core.mapreduce.MapReduceOptions;
import org.springframework.data.mongodb.core.query.BasicQuery;
import org.springframework.data.mongodb.core.query.Collation;
@@ -2772,7 +2762,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
DocumentCallback<T> readCallback = new ProjectingReadCallback<>(mongoConverter, projection, collectionName);
return resultConverter == QueryResultConverter.entity() ? (DocumentCallback<R>) readCallback
: new QueryResultConverterCallback<T, R>(resultConverter, readCallback);
: new QueryResultConverterCallback<>(resultConverter, readCallback);
}
/**

View File

@@ -19,7 +19,9 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.springframework.data.geo.Point;
import com.fasterxml.jackson.core.JsonParser;
@@ -163,7 +165,7 @@ public class GeoJsonModule extends SimpleModule {
* {@literal x - coordinate} and {@code node.[1]} is {@literal y}.
*
* @param node can be {@literal null}.
* @return {@literal null} when given a {@code null} value.
* @return {@literal null} when given a {@literal null} value.
*/
protected @Nullable GeoJsonPoint toGeoJsonPoint(@Nullable ArrayNode node) {
@@ -179,7 +181,7 @@ public class GeoJsonModule extends SimpleModule {
* {@literal x - coordinate} and {@code node.[1]} is {@literal y}.
*
* @param node can be {@literal null}.
* @return {@literal null} when given a {@code null} value.
* @return {@literal null} when given a {@literal null} value.
*/
protected @Nullable Point toPoint(@Nullable ArrayNode node) {
@@ -194,7 +196,7 @@ public class GeoJsonModule extends SimpleModule {
* Get the points nested within given {@link ArrayNode}.
*
* @param node can be {@literal null}.
* @return {@literal empty list} when given a {@code null} value.
* @return {@literal empty list} when given a {@literal null} value.
*/
protected List<Point> toPoints(@Nullable ArrayNode node) {

View File

@@ -110,7 +110,7 @@ public class MongoPersistentEntityIndexResolver implements IndexResolver {
* {@link GeospatialIndex}. The given {@literal root} has therefore to be annotated with {@link Document}.
*
* @param root must not be null.
* @return List of {@link IndexDefinitionHolder}. Will never be {@code null}.
* @return List of {@link IndexDefinitionHolder}. Will never be {@literal null}.
* @throws IllegalArgumentException in case of missing {@link Document} annotation marking root entities.
*/
public List<IndexDefinitionHolder> resolveIndexForEntity(MongoPersistentEntity<?> root) {
@@ -189,7 +189,7 @@ public class MongoPersistentEntityIndexResolver implements IndexResolver {
* @param collection
* @param guard
* @return List of {@link IndexDefinitionHolder} representing indexes for given type and its referenced property
* types. Will never be {@code null}.
* types. Will never be {@literal null}.
*/
private List<IndexDefinitionHolder> resolveIndexForClass(TypeInformation<?> type, String dotPath, Path path,
String collection, CycleGuard guard) {

View File

@@ -191,7 +191,7 @@ public class MongoQueryMethod extends QueryMethod {
}
/**
* Returns the {@link Query} annotation that is applied to the method or {@code null} if none available.
* Returns the {@link Query} annotation that is applied to the method or {@literal null} if none available.
*
* @return
*/
@@ -217,7 +217,7 @@ public class MongoQueryMethod extends QueryMethod {
}
/**
* Returns the {@link Meta} annotation that is applied to the method or {@code null} if not available.
* Returns the {@link Meta} annotation that is applied to the method or {@literal null} if not available.
*
* @return
* @since 1.6
@@ -228,7 +228,7 @@ public class MongoQueryMethod extends QueryMethod {
}
/**
* Returns the {@link Tailable} annotation that is applied to the method or {@code null} if not available.
* Returns the {@link Tailable} annotation that is applied to the method or {@literal null} if not available.
*
* @return
* @since 2.0

View File

@@ -172,7 +172,7 @@ class ExecutableFindOperationSupportTests implements StateFunctions {
.hasOnlyElementsOfType(Jedi.class).hasSize(1);
}
@Test // GH-
@Test // GH-4949
void findAllByWithConverter() {
List<Optional<Jedi>> result = template.query(Person.class).as(Jedi.class)
@@ -272,7 +272,7 @@ class ExecutableFindOperationSupportTests implements StateFunctions {
}
}
@Test // GH-
@Test // GH-4949
void streamAllWithConverter() {
try (Stream<Optional<Jedi>> stream = template.query(Person.class).as(Jedi.class)
@@ -336,7 +336,7 @@ class ExecutableFindOperationSupportTests implements StateFunctions {
assertThat(results.getContent().get(0).getContent().getId()).isEqualTo("alderan");
}
@Test // GH-
@Test // GH-4949
void findAllNearByWithConverter() {
GeoResults<Optional<Human>> results = template.query(Object.class).inCollection(STAR_WARS_PLANETS).as(Human.class)

View File

@@ -109,7 +109,7 @@ class ExecutableRemoveOperationSupportTests {
assertThat(result).containsExactly(han);
}
@Test // GH-0
@Test // GH-4949
void removeAndReturnAllMatchingWithResultConverter() {
List<Optional<Person>> result = template.remove(Person.class).matching(query(where("firstname").is("han"))).map((raw, converted) -> Optional.of(converted.get())).findAndRemove();

View File

@@ -293,14 +293,14 @@ class ExecutableUpdateOperationSupportTests {
assertThat(result.getName()).isEqualTo(han.firstname);
}
@Test // GH-
@Test // GH-4949
void findAndReplaceWithResultConverter() {
Person luke = new Person();
luke.firstname = "Luke";
Optional<Jedi> result = template.update(Person.class).matching(queryHan()).replaceWith(luke).as(Jedi.class) //
.mapResult((raw, converted) -> Optional.of(converted.get()))
.map((raw, converted) -> Optional.of(converted.get()))
.findAndReplaceValue();
assertThat(result.get()).isInstanceOf(Jedi.class).extracting(Jedi::getName).isEqualTo(han.firstname);

View File

@@ -15,13 +15,16 @@
*/
package org.springframework.data.mongodb.core;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.*;
import org.bson.Document;
import org.junit.jupiter.api.Test;
import org.springframework.data.mongodb.core.QueryResultConverter.ConversionResultSupplier;
/**
* Unit tests for {@link QueryResultConverter}.
*
* @author Christoph Strobl
*/
class QueryResultConverterUnitTests {
@@ -30,7 +33,7 @@ class QueryResultConverterUnitTests {
throw new IllegalStateException("must not read conversion result");
};
@Test // GH-
@Test // GH-4949
void converterDoesNotEagerlyRetrieveConversionResultFromSupplier() {
QueryResultConverter<Document, String> converter = new QueryResultConverter<Document, String>() {
@@ -44,7 +47,7 @@ class QueryResultConverterUnitTests {
assertThat(converter.mapDocument(new Document(), ERROR_SUPPLIER)).isEqualTo("done");
}
@Test // GH-
@Test // GH-4949
void converterPassesOnConversionResultToNextStage() {
Document source = new Document("value", "10");
@@ -68,7 +71,7 @@ class QueryResultConverterUnitTests {
assertThat(stagedConverter.mapDocument(source, ERROR_SUPPLIER)).isEqualTo(10);
}
@Test // GH-
@Test // GH-4949
void entityConverterDelaysConversion() {
Document source = new Document("value", "10");

View File

@@ -168,7 +168,7 @@ class ReactiveFindOperationSupportTests implements StateFunctions {
.verifyComplete();
}
@Test // GH-
@Test // GH-4949
void findAllWithConverter() {
template.query(Person.class).as(Jedi.class).map((document, reader) -> Optional.of(reader.get())).all()

View File

@@ -288,7 +288,7 @@ public class AggregationTests {
}
}
@Test // GH-
@Test // GH-4949
void shouldAggregateAsStreamWithConverter() {
MongoCollection<Document> coll = mongoTemplate.getCollection(INPUT_COLLECTION);
@@ -315,7 +315,7 @@ public class AggregationTests {
}
}
@Test // GH-
@Test // GH-4949
void shouldAggregateWithConverter() {
MongoCollection<Document> coll = mongoTemplate.getCollection(INPUT_COLLECTION);

View File

@@ -116,7 +116,7 @@ public class ReactiveAggregationTests {
}).verifyComplete();
}
@Test // GH-
@Test // GH-4949
public void shouldProjectAndConvertMultipleDocuments() {
City dresden = new City("Dresden", 100);