Add Nullable annotation to parameter of overridden equals method.

Closes: #4226
Original pull request: #4277
This commit is contained in:
Christoph Strobl
2022-11-08 12:28:47 +01:00
committed by Mark Paluch
parent c069e094e6
commit fe549f7254
49 changed files with 85 additions and 57 deletions

View File

@@ -219,7 +219,7 @@ public class ChangeStreamEvent<T> {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;

View File

@@ -164,7 +164,7 @@ public class ChangeStreamOptions {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())

View File

@@ -550,7 +550,7 @@ class DefaultBulkOperations implements BulkOperations {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
@@ -619,7 +619,7 @@ class DefaultBulkOperations implements BulkOperations {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())

View File

@@ -225,7 +225,7 @@ public abstract class MongoDatabaseFactorySupport<C> implements MongoDatabaseFac
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())

View File

@@ -231,7 +231,7 @@ public class SimpleReactiveMongoDatabaseFactory implements DisposableBean, React
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())

View File

@@ -294,7 +294,7 @@ public final class ExposedFields implements Iterable<ExposedField> {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
@@ -387,7 +387,7 @@ public final class ExposedFields implements Iterable<ExposedField> {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
@@ -454,7 +454,7 @@ public final class ExposedFields implements Iterable<ExposedField> {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -302,7 +302,7 @@ public final class Fields implements Iterable<Field> {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -19,6 +19,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -63,7 +64,7 @@ public class GeoJsonGeometryCollection implements GeoJson<Iterable<GeoJson<?>>>
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -20,6 +20,7 @@ import java.util.Collections;
import java.util.List;
import org.springframework.data.geo.Point;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -78,7 +79,7 @@ public class GeoJsonMultiLineString implements GeoJson<Iterable<GeoJsonLineStrin
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -21,6 +21,7 @@ import java.util.Collections;
import java.util.List;
import org.springframework.data.geo.Point;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -100,7 +101,7 @@ public class GeoJsonMultiPoint implements GeoJson<Iterable<Point>> {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -19,6 +19,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -62,7 +63,7 @@ public class GeoJsonMultiPolygon implements GeoJson<Iterable<GeoJsonPolygon>> {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -23,6 +23,7 @@ import java.util.List;
import org.springframework.data.geo.Point;
import org.springframework.data.geo.Polygon;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -137,7 +138,7 @@ public class GeoJsonPolygon extends Polygon implements GeoJson<List<GeoJsonLineS
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@@ -23,6 +23,7 @@ import org.springframework.data.geo.Circle;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Point;
import org.springframework.data.geo.Shape;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -98,7 +99,7 @@ public class Sphere implements Shape {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -175,7 +175,7 @@ public final class IndexField {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -283,7 +283,7 @@ public class IndexInfo {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}

View File

@@ -996,7 +996,7 @@ public class MongoPersistentEntityIndexResolver implements IndexResolver {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())

View File

@@ -197,7 +197,7 @@ public class TextIndexDefinition implements IndexDefinition {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.data.mongodb.core.mapping;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
@@ -35,7 +36,7 @@ class UnwrapEntityContext {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -341,7 +341,7 @@ class UnwrappedMongoPersistentProperty implements MongoPersistentProperty {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -15,6 +15,8 @@
*/
package org.springframework.data.mongodb.core.mapreduce;
import org.springframework.lang.Nullable;
/**
* Value object to encapsulate results of a map-reduce count.
*
@@ -77,7 +79,7 @@ public class MapReduceCounts {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}

View File

@@ -15,6 +15,8 @@
*/
package org.springframework.data.mongodb.core.mapreduce;
import org.springframework.lang.Nullable;
/**
* @deprecated since 3.4 in favor of {@link org.springframework.data.mongodb.core.aggregation}.
*/
@@ -61,7 +63,7 @@ public class MapReduceTiming {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -244,7 +244,7 @@ public class DefaultMessageListenerContainer implements MessageListenerContainer
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())

View File

@@ -120,7 +120,7 @@ public interface Message<S, T> {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())

View File

@@ -61,7 +61,7 @@ class SimpleMessage<S, T> implements Message<S, T> {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())

View File

@@ -152,7 +152,7 @@ public class BasicQuery extends Query {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;

View File

@@ -20,6 +20,7 @@ import java.util.Optional;
import org.bson.Document;
import org.springframework.core.convert.converter.Converter;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -399,7 +400,7 @@ public class Collation {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;

View File

@@ -971,7 +971,7 @@ public class Criteria implements CriteriaDefinition {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -241,7 +241,7 @@ public class Field {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;

View File

@@ -22,6 +22,7 @@ import org.springframework.data.geo.Circle;
import org.springframework.data.geo.Polygon;
import org.springframework.data.geo.Shape;
import org.springframework.data.mongodb.core.geo.Sphere;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -99,7 +100,7 @@ public final class GeoCommand {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -244,7 +244,7 @@ public class Meta {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -563,7 +563,7 @@ public class Query {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -92,7 +92,7 @@ public class Term {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;

View File

@@ -225,7 +225,7 @@ public class TextCriteria implements CriteriaDefinition {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;

View File

@@ -18,6 +18,7 @@ package org.springframework.data.mongodb.core.query;
import java.util.Set;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
@@ -131,7 +132,7 @@ public class UntypedExampleMatcher implements ExampleMatcher {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;

View File

@@ -486,7 +486,7 @@ public class Update implements UpdateDefinition {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
@@ -552,7 +552,7 @@ public class Update implements UpdateDefinition {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
@@ -613,7 +613,7 @@ public class Update implements UpdateDefinition {
}
@Override
public boolean equals(Object that) {
public boolean equals(@Nullable Object that) {
if (this == that) {
return true;
@@ -907,7 +907,7 @@ public class Update implements UpdateDefinition {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -517,7 +517,7 @@ public interface JsonSchemaObject {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
@@ -557,7 +557,7 @@ public interface JsonSchemaObject {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;

View File

@@ -19,6 +19,7 @@ import org.bson.Document;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.CriteriaDefinition;
import org.springframework.data.mongodb.core.query.SerializationUtils;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -65,7 +66,7 @@ class CriteriaValidator implements Validator {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())

View File

@@ -17,6 +17,7 @@ package org.springframework.data.mongodb.core.validation;
import org.bson.Document;
import org.springframework.data.mongodb.core.query.SerializationUtils;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -61,7 +62,7 @@ class DocumentValidator implements Validator {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;

View File

@@ -18,6 +18,7 @@ package org.springframework.data.mongodb.core.validation;
import org.bson.Document;
import org.springframework.data.mongodb.core.query.SerializationUtils;
import org.springframework.data.mongodb.core.schema.MongoJsonSchema;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -61,7 +62,7 @@ class JsonSchemaValidator implements Validator {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;

View File

@@ -87,6 +87,7 @@ import org.springframework.data.mongodb.test.util.Client;
import org.springframework.data.mongodb.test.util.MongoClientExtension;
import org.springframework.data.mongodb.test.util.MongoTestTemplate;
import org.springframework.data.mongodb.test.util.MongoVersion;
import org.springframework.lang.Nullable;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
@@ -3859,7 +3860,7 @@ public class MongoTemplateTests {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
@@ -4102,7 +4103,7 @@ public class MongoTemplateTests {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (obj == this) {
return true;

View File

@@ -16,6 +16,7 @@
package org.springframework.data.mongodb.core;
import org.bson.types.ObjectId;
import org.springframework.lang.Nullable;
public class Person {
@@ -90,7 +91,7 @@ public class Person {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (obj == this) {
return true;
}

View File

@@ -15,6 +15,8 @@
*/
package org.springframework.data.mongodb.core;
import org.springframework.lang.Nullable;
public class User {
@Override
@@ -27,7 +29,7 @@ public class User {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj)
return true;
if (obj == null)

View File

@@ -55,6 +55,7 @@ import org.springframework.data.mongodb.core.convert.MappingMongoConverterUnitTe
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
import org.springframework.lang.Nullable;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.util.SerializationUtils;
@@ -847,7 +848,7 @@ class DbRefMappingMongoConverterUnitTests {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj)
return true;
if (obj == null)

View File

@@ -37,6 +37,7 @@ import org.springframework.data.mongodb.core.query.TextQueryTests.FullTextDoc.Fu
import org.springframework.data.mongodb.test.util.MongoTemplateExtension;
import org.springframework.data.mongodb.test.util.MongoTestTemplate;
import org.springframework.data.mongodb.test.util.Template;
import org.springframework.lang.Nullable;
/**
* @author Christoph Strobl
@@ -251,7 +252,7 @@ public class TextQueryTests {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.data.mongodb.repository;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
import com.querydsl.core.annotations.QueryEmbeddable;
@@ -87,7 +88,7 @@ public class Address {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

View File

@@ -38,6 +38,7 @@ import org.springframework.data.mongodb.repository.support.MongoRepositoryFactor
import org.springframework.data.mongodb.test.util.MongoTemplateExtension;
import org.springframework.data.mongodb.test.util.MongoTestTemplate;
import org.springframework.data.mongodb.test.util.Template;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
@@ -232,7 +233,7 @@ class MongoRepositoryTextSearchIntegrationTests {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}

View File

@@ -17,6 +17,7 @@ package org.springframework.data.mongodb.repository;
import java.io.Serializable;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
@@ -42,7 +43,7 @@ public class MyId implements Serializable {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (obj == this) {
return true;

View File

@@ -30,6 +30,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.DocumentReference;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.data.mongodb.core.mapping.Unwrapped;
import org.springframework.lang.Nullable;
/**
* Sample domain class.
@@ -275,7 +276,7 @@ public class Person extends Contact {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -17,6 +17,7 @@ package org.springframework.data.mongodb.repository;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
@@ -40,7 +41,7 @@ public class UserWithComplexId {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (obj == this) {
return true;