15
15
*/
16
16
package org .springframework .data .mongodb .core .query ;
17
17
18
- import static org .springframework .util .ObjectUtils .nullSafeHashCode ;
18
+ import static org .springframework .util .ObjectUtils .* ;
19
19
20
20
import java .util .ArrayList ;
21
21
import java .util .Arrays ;
34
34
import org .bson .Document ;
35
35
import org .bson .types .Binary ;
36
36
import org .jspecify .annotations .Nullable ;
37
+
37
38
import org .springframework .data .domain .Example ;
38
39
import org .springframework .data .geo .Circle ;
39
40
import org .springframework .data .geo .Point ;
@@ -76,8 +77,8 @@ public class Criteria implements CriteriaDefinition {
76
77
private static final Object NOT_SET = new Object ();
77
78
78
79
private @ Nullable String key ;
79
- private List <Criteria > criteriaChain ;
80
- private LinkedHashMap <String , Object > criteria = new LinkedHashMap <String , Object >();
80
+ private final List <Criteria > criteriaChain ;
81
+ private final LinkedHashMap <String , @ Nullable Object > criteria = new LinkedHashMap <String , Object >();
81
82
private @ Nullable Object isValue = NOT_SET ;
82
83
83
84
public Criteria () {
@@ -120,7 +121,7 @@ public static Criteria byExample(Object example) {
120
121
121
122
/**
122
123
* Static factory method to create a {@link Criteria} matching an example object. <br />
123
- * By default the {@link Example} uses typed matching restricting it to probe assignable types. For example, when
124
+ * By default, the {@link Example} uses typed matching restricting it to probe assignable types. For example, when
124
125
* sticking with the default type key ({@code _class}), the query has restrictions such as
125
126
* <code>_class : { $in : [com.acme.Person] } </code>. <br />
126
127
* To avoid the above-mentioned type restriction use an {@link UntypedExampleMatcher} with
@@ -224,7 +225,7 @@ public Criteria is(@Nullable Object value) {
224
225
* Missing Fields: Equality Filter</a>
225
226
* @since 3.3
226
227
*/
227
- @ Contract ("_ -> this" )
228
+ @ Contract ("-> this" )
228
229
public Criteria isNull () {
229
230
return is (null );
230
231
}
@@ -241,7 +242,7 @@ public Criteria isNull() {
241
242
* Fields: Type Check</a>
242
243
* @since 3.3
243
244
*/
244
- @ Contract ("_ -> this" )
245
+ @ Contract ("-> this" )
245
246
public Criteria isNullValue () {
246
247
247
248
criteria .put ("$type" , BsonType .NULL .getValue ());
@@ -391,7 +392,7 @@ public Criteria nin(Collection<?> values) {
391
392
* @return this.
392
393
* @see <a href="https://docs.mongodb.com/manual/reference/operator/query/mod/">MongoDB Query operator: $mod</a>
393
394
*/
394
- @ Contract ("_ -> this" )
395
+ @ Contract ("_, _ -> this" )
395
396
public Criteria mod (Number value , Number remainder ) {
396
397
List <Object > l = new ArrayList <>(2 );
397
398
l .add (value );
@@ -818,7 +819,7 @@ public BitwiseCriteriaOperators bits() {
818
819
}
819
820
820
821
/**
821
- * Creates a criteria using the {@code $or} operator for all of the provided criteria.
822
+ * Creates a criteria using the {@code $or} operator for all provided criteria.
822
823
* <p>
823
824
* Note that MongoDB doesn't support an {@code $nor} operator to be wrapped in a {@code $not} operator.
824
825
*
@@ -933,6 +934,7 @@ public Criteria andOperator(Collection<Criteria> criteria) {
933
934
* @return this
934
935
* @since 5.0
935
936
*/
937
+ @ Contract ("_, _ -> this" )
936
938
public Criteria raw (String operator , Object value ) {
937
939
criteria .put (operator , value );
938
940
return this ;
@@ -957,6 +959,7 @@ private Criteria registerCriteriaChainElement(Criteria criteria) {
957
959
return this .key ;
958
960
}
959
961
962
+ @ Override
960
963
public Document getCriteriaObject () {
961
964
962
965
if (this .criteriaChain .size () == 1 ) {
0 commit comments