111111import org .springframework .data .mongodb .core .timeseries .Granularity ;
112112import org .springframework .data .mongodb .core .validation .Validator ;
113113import org .springframework .data .projection .EntityProjection ;
114- import org .springframework .data .projection .ProjectionFactory ;
115114import org .springframework .data .util .CloseableIterator ;
116115import org .springframework .data .util .Lazy ;
117116import org .springframework .data .util .Optionals ;
118- import org .springframework .data .util .TypeInformation ;
119117import org .springframework .lang .Contract ;
120118import org .springframework .util .Assert ;
121119import org .springframework .util .ClassUtils ;
@@ -498,7 +496,7 @@ protected <T> Stream<T> doStream(Query query, Class<?> entityType, String collec
498496 return doStream (query , entityType , collectionName , returnType , QueryResultConverter .entity ());
499497 }
500498
501- @ SuppressWarnings ({"ConstantConditions" , "NullAway" })
499+ @ SuppressWarnings ({ "ConstantConditions" , "NullAway" })
502500 <T , R > Stream <R > doStream (Query query , Class <?> entityType , String collectionName , Class <T > returnType ,
503501 QueryResultConverter <? super T , ? extends R > resultConverter ) {
504502
@@ -523,8 +521,7 @@ <T, R> Stream<R> doStream(Query query, Class<?> entityType, String collectionNam
523521
524522 DocumentCallback <R > resultReader = getResultReader (projection , collectionName , resultConverter );
525523
526- return new CloseableIterableCursorAdapter <>(cursor , exceptionTranslator ,
527- resultReader ).stream ();
524+ return new CloseableIterableCursorAdapter <>(cursor , exceptionTranslator , resultReader ).stream ();
528525 });
529526 }
530527
@@ -1152,7 +1149,7 @@ <T, R> GeoResults<R> doGeoNear(NearQuery near, Class<?> domainType, String colle
11521149
11531150 @ Override
11541151 public <T > @ Nullable T findAndModify (Query query , UpdateDefinition update , FindAndModifyOptions options ,
1155- Class <T > entityClass , String collectionName ) {
1152+ Class <T > entityClass , String collectionName ) {
11561153 return findAndModify (query , update , options , entityClass , collectionName , QueryResultConverter .entity ());
11571154 }
11581155
@@ -1182,12 +1179,13 @@ <T, R> GeoResults<R> doGeoNear(NearQuery near, Class<?> domainType, String colle
11821179
11831180 @ Override
11841181 public <S , T > @ Nullable T findAndReplace (Query query , S replacement , FindAndReplaceOptions options ,
1185- Class <S > entityType , String collectionName , Class <T > resultType ) {
1186- return findAndReplace (query , replacement , options , entityType , collectionName , resultType , QueryResultConverter .entity ());
1182+ Class <S > entityType , String collectionName , Class <T > resultType ) {
1183+ return findAndReplace (query , replacement , options , entityType , collectionName , resultType ,
1184+ QueryResultConverter .entity ());
11871185 }
11881186
1189- <S , T , R > @ Nullable R findAndReplace (Query query , S replacement , FindAndReplaceOptions options ,
1190- Class < S > entityType , String collectionName , Class <T > resultType , QueryResultConverter <? super T , ? extends R > resultConverter ) {
1187+ <S , T , R > @ Nullable R findAndReplace (Query query , S replacement , FindAndReplaceOptions options , Class < S > entityType ,
1188+ String collectionName , Class <T > resultType , QueryResultConverter <? super T , ? extends R > resultConverter ) {
11911189
11921190 Assert .notNull (query , "Query must not be null" );
11931191 Assert .notNull (replacement , "Replacement must not be null" );
@@ -1215,7 +1213,8 @@ <T, R> GeoResults<R> doGeoNear(NearQuery near, Class<?> domainType, String colle
12151213 maybeCallBeforeSave (replacement , mappedReplacement , collectionName );
12161214
12171215 R saved = doFindAndReplace (collectionPreparer , collectionName , mappedQuery , mappedFields , mappedSort ,
1218- queryContext .getCollation (entityType ).orElse (null ), entityType , mappedReplacement , options , projection , resultConverter );
1216+ queryContext .getCollation (entityType ).orElse (null ), entityType , mappedReplacement , options , projection ,
1217+ resultConverter );
12191218
12201219 if (saved != null ) {
12211220 maybeEmitEvent (new AfterSaveEvent <>(saved , mappedReplacement , collectionName ));
@@ -1508,7 +1507,7 @@ protected <T> Collection<T> doInsertBatch(String collectionName, Collection<? ex
15081507 initialized = maybeCallBeforeSave (initialized , document , collectionName );
15091508
15101509 MappedDocument mappedDocument = queryOperations .createInsertContext (MappedDocument .of (document ))
1511- .prepareId (uninitialized .getClass ());
1510+ .prepareId (uninitialized .getClass ());
15121511
15131512 documentList .add (mappedDocument .getDocument ());
15141513 initializedBatchToSave .add (initialized );
@@ -2221,14 +2220,14 @@ public T doWith(Document object) {
22212220 }
22222221 };
22232222
2224- List <T > result = doFind (collectionName , createDelegate (query ), query .getQueryObject (), query .getFieldsObject (), entityClass ,
2225- new QueryCursorPreparer (query , entityClass ), callback );
2223+ List <T > result = doFind (collectionName , createDelegate (query ), query .getQueryObject (), query .getFieldsObject (),
2224+ entityClass , new QueryCursorPreparer (query , entityClass ), callback );
22262225
22272226 if (!CollectionUtils .isEmpty (result )) {
22282227
22292228 Criteria [] criterias = ids .stream () //
2230- .map (it -> Criteria .where ("_id" ).is (it )) //
2231- .toArray (Criteria []::new );
2229+ .map (it -> Criteria .where ("_id" ).is (it )) //
2230+ .toArray (Criteria []::new );
22322231
22332232 Query removeQuery = new Query (criterias .length == 1 ? criterias [0 ] : new Criteria ().orOperator (criterias ));
22342233 if (query .hasReadPreference ()) {
@@ -2270,20 +2269,19 @@ protected <O> AggregationResults<O> doAggregate(Aggregation aggregation, String
22702269 return doAggregate (aggregation , collectionName , outputType , QueryResultConverter .entity (), context );
22712270 }
22722271
2273- @ SuppressWarnings ({"ConstantConditions" , "NullAway" })
2272+ @ SuppressWarnings ({ "ConstantConditions" , "NullAway" })
22742273 <T , O > AggregationResults <O > doAggregate (Aggregation aggregation , String collectionName , Class <T > outputType ,
22752274 QueryResultConverter <? super T , ? extends O > resultConverter , AggregationOperationContext context ) {
22762275
22772276 final DocumentCallback <O > callback ;
2278- if (aggregation instanceof TypedAggregation <?> ta && outputType .isInterface ()) {
2277+ if (aggregation instanceof TypedAggregation <?> ta && outputType .isInterface ()) {
22792278 EntityProjection <T , ?> projection = operations .introspectProjection (outputType , ta .getInputType ());
22802279 ProjectingReadCallback cb = new ProjectingReadCallback (mongoConverter , projection , collectionName );
2281- callback = new QueryResultConverterCallback <>(resultConverter ,
2282- cb );
2280+ callback = new QueryResultConverterCallback <>(resultConverter , cb );
22832281 } else {
22842282
22852283 callback = new QueryResultConverterCallback <>(resultConverter ,
2286- new ReadDocumentCallback <>(mongoConverter , outputType , collectionName ));
2284+ new ReadDocumentCallback <>(mongoConverter , outputType , collectionName ));
22872285 }
22882286
22892287 AggregationOptions options = aggregation .getOptions ();
@@ -2370,8 +2368,7 @@ protected <O> Stream<O> aggregateStream(Aggregation aggregation, String collecti
23702368
23712369 @ SuppressWarnings ({ "ConstantConditions" , "NullAway" })
23722370 <T , O > Stream <O > doAggregateStream (Aggregation aggregation , String collectionName , Class <T > outputType ,
2373- QueryResultConverter <? super T , ? extends O > resultConverter ,
2374- @ Nullable AggregationOperationContext context ) {
2371+ QueryResultConverter <? super T , ? extends O > resultConverter , @ Nullable AggregationOperationContext context ) {
23752372
23762373 Assert .notNull (aggregation , "Aggregation pipeline must not be null" );
23772374 Assert .hasText (collectionName , "Collection name must not be null or empty" );
@@ -2649,9 +2646,8 @@ private CreateCollectionOptions getCreateCollectionOptions(Document document) {
26492646 * @return the converted object or {@literal null} if none exists.
26502647 */
26512648 @ Nullable
2652- protected <T > T doFindOne (String collectionName ,
2653- CollectionPreparer <MongoCollection <Document >> collectionPreparer , Document query , Document fields ,
2654- Class <T > entityClass ) {
2649+ protected <T > T doFindOne (String collectionName , CollectionPreparer <MongoCollection <Document >> collectionPreparer ,
2650+ Document query , Document fields , Class <T > entityClass ) {
26552651 return doFindOne (collectionName , collectionPreparer , query , fields , CursorPreparer .NO_OP_PREPARER , entityClass );
26562652 }
26572653
@@ -2670,9 +2666,8 @@ protected <T> T doFindOne(String collectionName,
26702666 */
26712667 @ Nullable
26722668 @ SuppressWarnings ("ConstantConditions" )
2673- protected <T > T doFindOne (String collectionName ,
2674- CollectionPreparer <MongoCollection <Document >> collectionPreparer , Document query , Document fields ,
2675- CursorPreparer preparer , Class <T > entityClass ) {
2669+ protected <T > T doFindOne (String collectionName , CollectionPreparer <MongoCollection <Document >> collectionPreparer ,
2670+ Document query , Document fields , CursorPreparer preparer , Class <T > entityClass ) {
26762671
26772672 MongoPersistentEntity <?> entity = mappingContext .getPersistentEntity (entityClass );
26782673
@@ -2870,9 +2865,9 @@ Document getMappedValidator(Validator validator, Class<?> domainType) {
28702865
28712866 @ SuppressWarnings ("ConstantConditions" )
28722867 <S , T > @ Nullable T doFindAndModify (CollectionPreparer <MongoCollection <Document >> collectionPreparer ,
2873- String collectionName ,
2874- Document query , @ Nullable Document fields , @ Nullable Document sort , Class < S > entityClass , UpdateDefinition update ,
2875- @ Nullable FindAndModifyOptions options , QueryResultConverter <? super S , ? extends T > resultConverter ) {
2868+ String collectionName , Document query , @ Nullable Document fields , @ Nullable Document sort , Class < S > entityClass ,
2869+ UpdateDefinition update , @ Nullable FindAndModifyOptions options ,
2870+ QueryResultConverter <? super S , ? extends T > resultConverter ) {
28762871
28772872 if (options == null ) {
28782873 options = new FindAndModifyOptions ();
@@ -2894,7 +2889,8 @@ Document getMappedValidator(Validator validator, Class<?> domainType) {
28942889 serializeToJsonSafely (mappedUpdate ), collectionName ));
28952890 }
28962891
2897- DocumentCallback <T > callback = getResultReader (EntityProjection .nonProjecting (entityClass ), collectionName , resultConverter );
2892+ DocumentCallback <T > callback = getResultReader (EntityProjection .nonProjecting (entityClass ), collectionName ,
2893+ resultConverter );
28982894
28992895 return executeFindOneInternal (
29002896 new FindAndModifyCallback (collectionPreparer , mappedQuery , fields , sort , mappedUpdate ,
@@ -2919,8 +2915,7 @@ Document getMappedValidator(Validator validator, Class<?> domainType) {
29192915 */
29202916 @ Nullable
29212917 protected <S , T > T doFindAndReplace (CollectionPreparer <MongoCollection <Document >> collectionPreparer ,
2922- String collectionName ,
2923- Document mappedQuery , Document mappedFields , Document mappedSort ,
2918+ String collectionName , Document mappedQuery , Document mappedFields , Document mappedSort ,
29242919 com .mongodb .client .model .@ Nullable Collation collation , Class <S > entityType , Document replacement ,
29252920 FindAndReplaceOptions options , Class <T > resultType ) {
29262921
@@ -2963,10 +2958,10 @@ CollectionPreparer<MongoCollection<Document>> createCollectionPreparer(Query que
29632958 */
29642959 @ Nullable
29652960 private <S , T , R > R doFindAndReplace (CollectionPreparer <MongoCollection <Document >> collectionPreparer ,
2966- String collectionName ,
2967- Document mappedQuery , Document mappedFields , Document mappedSort ,
2961+ String collectionName , Document mappedQuery , Document mappedFields , Document mappedSort ,
29682962 com .mongodb .client .model .@ Nullable Collation collation , Class <T > entityType , Document replacement ,
2969- FindAndReplaceOptions options , EntityProjection <S , T > projection , QueryResultConverter <? super S , ? extends R > resultConverter ) {
2963+ FindAndReplaceOptions options , EntityProjection <S , T > projection ,
2964+ QueryResultConverter <? super S , ? extends R > resultConverter ) {
29702965
29712966 if (LOGGER .isDebugEnabled ()) {
29722967 LOGGER
@@ -2979,8 +2974,7 @@ private <S, T, R> R doFindAndReplace(CollectionPreparer<MongoCollection<Document
29792974
29802975 DocumentCallback <R > callback = getResultReader (projection , collectionName , resultConverter );
29812976 return executeFindOneInternal (new FindAndReplaceCallback (collectionPreparer , mappedQuery , mappedFields , mappedSort ,
2982- replacement , collation , options ),callback ,
2983- collectionName );
2977+ replacement , collation , options ), callback , collectionName );
29842978 }
29852979
29862980 @ SuppressWarnings ("NullAway" )
@@ -3158,8 +3152,8 @@ private Document getMappedSortObject(@Nullable Query query, Class<?> type) {
31583152 return getMappedSortObject (sortObject , mappingContext .getPersistentEntity (type ));
31593153 }
31603154
3161-
3162- private @ Nullable Document getMappedSortObject ( @ Nullable Document sortObject , @ Nullable MongoPersistentEntity <?> entity ) {
3155+ private @ Nullable Document getMappedSortObject ( @ Nullable Document sortObject ,
3156+ @ Nullable MongoPersistentEntity <?> entity ) {
31633157
31643158 if (ObjectUtils .isEmpty (sortObject )) {
31653159 return null ;
@@ -3392,7 +3386,7 @@ private static class FindAndReplaceCallback implements CollectionCallback<Docume
33923386 private final Document fields ;
33933387 private final Document sort ;
33943388 private final Document update ;
3395- private final com .mongodb .client .model .@ Nullable Collation collation ;
3389+ private final com .mongodb .client .model .@ Nullable Collation collation ;
33963390 private final FindAndReplaceOptions options ;
33973391
33983392 FindAndReplaceCallback (CollectionPreparer <MongoCollection <Document >> collectionPreparer , Document query ,
0 commit comments