Skip to content

Commit f79dc39

Browse files
unlimitedsolamp911de
authored andcommitted
DATAMONGO-1817 - Align nullability in Kotlin MongoOperationsExtensions with Java API.
Return types in MongoOperationsExtensions are now aligned to the nullability of MongoOperations. Original pull request: spring-projects#510.
1 parent 35abef4 commit f79dc39

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/MongoOperationsExtensions.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ inline fun <reified T : Any> MongoOperations.getCollectionName(): String =
5959
* @author Sebastien Deleuze
6060
* @since 2.0
6161
*/
62-
inline fun <reified T : Any> MongoOperations.execute(action: CollectionCallback<T>): T =
62+
inline fun <reified T : Any> MongoOperations.execute(action: CollectionCallback<T>): T? =
6363
execute(T::class.java, action)
6464

6565
/**
@@ -278,7 +278,7 @@ inline fun <reified T : Any> MongoOperations.geoNear(near: NearQuery, collection
278278
* @author Sebastien Deleuze
279279
* @since 2.0
280280
*/
281-
inline fun <reified T : Any> MongoOperations.findOne(query: Query, collectionName: String? = null): T =
281+
inline fun <reified T : Any> MongoOperations.findOne(query: Query, collectionName: String? = null): T? =
282282
if (collectionName != null) findOne(query, T::class.java, collectionName) else findOne(query, T::class.java)
283283

284284
/**
@@ -318,7 +318,7 @@ inline fun <reified T : Any> MongoOperations.find(query: Query, collectionName:
318318
* @author Sebastien Deleuze
319319
* @since 2.0
320320
*/
321-
inline fun <reified T : Any> MongoOperations.findById(id: Any, collectionName: String? = null): T =
321+
inline fun <reified T : Any> MongoOperations.findById(id: Any, collectionName: String? = null): T? =
322322
if (collectionName != null) findById(id, T::class.java, collectionName)
323323
else findById(id, T::class.java)
324324

@@ -328,7 +328,7 @@ inline fun <reified T : Any> MongoOperations.findById(id: Any, collectionName: S
328328
* @author Sebastien Deleuze
329329
* @since 2.0
330330
*/
331-
inline fun <reified T : Any> MongoOperations.findAndModify(query: Query, update: Update, options: FindAndModifyOptions, collectionName: String? = null): T =
331+
inline fun <reified T : Any> MongoOperations.findAndModify(query: Query, update: Update, options: FindAndModifyOptions, collectionName: String? = null): T? =
332332
if (collectionName != null) findAndModify(query, update, options, T::class.java, collectionName)
333333
else findAndModify(query, update, options, T::class.java)
334334

@@ -338,7 +338,7 @@ inline fun <reified T : Any> MongoOperations.findAndModify(query: Query, update:
338338
* @author Sebastien Deleuze
339339
* @since 2.0
340340
*/
341-
inline fun <reified T : Any> MongoOperations.findAndRemove(query: Query, collectionName: String? = null): T =
341+
inline fun <reified T : Any> MongoOperations.findAndRemove(query: Query, collectionName: String? = null): T? =
342342
if (collectionName != null) findAndRemove(query, T::class.java, collectionName)
343343
else findAndRemove(query, T::class.java)
344344

0 commit comments

Comments
 (0)