1515 */
1616package org .springframework .data .mongodb .core .query ;
1717
18- import static org .springframework .util .ObjectUtils .nullSafeHashCode ;
18+ import static org .springframework .util .ObjectUtils .* ;
1919
2020import java .util .ArrayList ;
2121import java .util .Arrays ;
3434import org .bson .Document ;
3535import org .bson .types .Binary ;
3636import org .jspecify .annotations .Nullable ;
37+
3738import org .springframework .data .domain .Example ;
3839import org .springframework .data .geo .Circle ;
3940import org .springframework .data .geo .Point ;
@@ -76,8 +77,8 @@ public class Criteria implements CriteriaDefinition {
7677 private static final Object NOT_SET = new Object ();
7778
7879 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 >();
8182 private @ Nullable Object isValue = NOT_SET ;
8283
8384 public Criteria () {
@@ -120,7 +121,7 @@ public static Criteria byExample(Object example) {
120121
121122 /**
122123 * 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
124125 * sticking with the default type key ({@code _class}), the query has restrictions such as
125126 * <code>_class : { $in : [com.acme.Person] } </code>. <br />
126127 * To avoid the above-mentioned type restriction use an {@link UntypedExampleMatcher} with
@@ -224,7 +225,7 @@ public Criteria is(@Nullable Object value) {
224225 * Missing Fields: Equality Filter</a>
225226 * @since 3.3
226227 */
227- @ Contract ("_ -> this" )
228+ @ Contract ("-> this" )
228229 public Criteria isNull () {
229230 return is (null );
230231 }
@@ -241,7 +242,7 @@ public Criteria isNull() {
241242 * Fields: Type Check</a>
242243 * @since 3.3
243244 */
244- @ Contract ("_ -> this" )
245+ @ Contract ("-> this" )
245246 public Criteria isNullValue () {
246247
247248 criteria .put ("$type" , BsonType .NULL .getValue ());
@@ -391,7 +392,7 @@ public Criteria nin(Collection<?> values) {
391392 * @return this.
392393 * @see <a href="https://docs.mongodb.com/manual/reference/operator/query/mod/">MongoDB Query operator: $mod</a>
393394 */
394- @ Contract ("_ -> this" )
395+ @ Contract ("_, _ -> this" )
395396 public Criteria mod (Number value , Number remainder ) {
396397 List <Object > l = new ArrayList <>(2 );
397398 l .add (value );
@@ -818,7 +819,7 @@ public BitwiseCriteriaOperators bits() {
818819 }
819820
820821 /**
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.
822823 * <p>
823824 * Note that MongoDB doesn't support an {@code $nor} operator to be wrapped in a {@code $not} operator.
824825 *
@@ -933,6 +934,7 @@ public Criteria andOperator(Collection<Criteria> criteria) {
933934 * @return this
934935 * @since 5.0
935936 */
937+ @ Contract ("_, _ -> this" )
936938 public Criteria raw (String operator , Object value ) {
937939 criteria .put (operator , value );
938940 return this ;
@@ -957,6 +959,7 @@ private Criteria registerCriteriaChainElement(Criteria criteria) {
957959 return this .key ;
958960 }
959961
962+ @ Override
960963 public Document getCriteriaObject () {
961964
962965 if (this .criteriaChain .size () == 1 ) {
0 commit comments