Skip to content

Commit 41ae2ca

Browse files
committed
DATAMONGO-2138 - Cleanup code
1 parent 20cfb37 commit 41ae2ca

File tree

3 files changed

+90
-54
lines changed

3 files changed

+90
-54
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ class TypedCriteriaBuilder {
315315
addOperation { andDocumentStructureMatches(schema) }
316316

317317
/**
318-
* Use [BitwiseCriteriaOperators] as gateway to create a criterion using one of the
318+
* Use [Criteria.BitwiseCriteriaOperators] as gateway to create a criterion using one of the
319319
* [bitwise operators](https://docs.mongodb.com/manual/reference/operator/query-bitwise/) like
320320
* `$bitsAllClear`.
321321
*
@@ -358,7 +358,7 @@ class TypedCriteriaBuilder {
358358
fun and(vararg builders: TypedCriteria) = addOperatorWithCriteria(builders, Criteria::andOperator)
359359

360360
private fun addOperatorWithCriteria(builders: Array<out TypedCriteria>, operation: Criteria.(Array<Criteria>) -> Criteria) {
361-
val otherCriteria = builders.map { TypedCriteriaBuilder().apply(it) }.map { it.criteria }
361+
val otherCriteria = builders.map { typedCriteria(it) }
362362
criteria.operation(otherCriteria.toTypedArray())
363363
}
364364

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,17 @@ package org.springframework.data.mongodb.core.query
2222
* @sample typedCriteriaSample
2323
* @author Tjeu Kayim
2424
*/
25-
fun typedCriteria(criteria: TypedCriteria): Criteria {
26-
val builder = TypedCriteriaBuilder().apply(criteria)
27-
return builder.criteria
28-
}
25+
fun typedCriteria(criteria: TypedCriteria): Criteria =
26+
TypedCriteriaBuilder().apply(criteria).criteria
2927

3028
/**
3129
* Shorthand for `Query(typedCriteria())`.
3230
*
3331
* @see typedCriteria
3432
* @author Tjeu Kayim
3533
*/
36-
fun typedQuery(criteria: TypedCriteria): Query {
37-
return Query(typedCriteria(criteria))
38-
}
34+
fun typedQuery(criteria: TypedCriteria): Query =
35+
Query(typedCriteria(criteria))
3936

4037
private fun typedCriteriaSample() {
4138
class Author(val name: String)

0 commit comments

Comments
 (0)