Consistently declare Object::equals argument as @Nullable

This commit is contained in:
Sam Brannen 2023-03-13 21:43:21 +01:00
parent a6dab10309
commit 00be19c647
74 changed files with 149 additions and 103 deletions

View File

@ -117,7 +117,7 @@ public class TypePatternClassFilter implements ClassFilter {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof TypePatternClassFilter that &&
ObjectUtils.nullSafeEquals(this.typePattern, that.typePattern)));
}

View File

@ -19,6 +19,7 @@ package org.springframework.aop.support;
import java.io.Serializable;
import org.springframework.aop.ClassFilter;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@ -45,7 +46,7 @@ public class RootClassFilter implements ClassFilter, Serializable {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof RootClassFilter that &&
this.clazz.equals(that.clazz)));
}

View File

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

View File

@ -21,6 +21,8 @@ import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.springframework.lang.Nullable;
/**
* Abstract superclass for counting advices etc.
*
@ -59,7 +61,7 @@ public class MethodCounter implements Serializable {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return (other != null && other.getClass() == this.getClass());
}

View File

@ -19,6 +19,8 @@ package org.springframework.aop.testfixture.interceptor;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.lang.Nullable;
/**
* Trivial interceptor that can be introduced in a chain to display it.
*
@ -45,14 +47,14 @@ public class NopInterceptor implements MethodInterceptor {
@Override
public boolean equals(Object other) {
if (!(other instanceof NopInterceptor)) {
return false;
}
if (this == other) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
return this.count == ((NopInterceptor) other).count;
if (!(obj instanceof NopInterceptor that)) {
return false;
}
return this.count == that.count;
}
@Override

View File

@ -16,6 +16,7 @@
package org.springframework.cache.config;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
@ -45,16 +46,11 @@ public class TestEntity {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (obj == this) {
return true;
}
if (obj == null) {
return false;
}
if (obj instanceof TestEntity) {
return ObjectUtils.nullSafeEquals(this.id, ((TestEntity) obj).id);
}
return false;
return (obj instanceof TestEntity that && ObjectUtils.nullSafeEquals(this.id, that.id));
}
}

View File

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

View File

@ -22,6 +22,7 @@ import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;
@ -194,7 +195,7 @@ public class PagedListHolderTests {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@ -16,6 +16,8 @@
package org.springframework.beans.testfixture.beans;
import org.springframework.lang.Nullable;
/**
* Simple nested test bean used for testing bean factories, AOP framework etc.
*
@ -43,7 +45,7 @@ public class NestedTestBean implements INestedTestBean {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (!(obj instanceof NestedTestBean ntb)) {
return false;
}

View File

@ -16,6 +16,8 @@
package org.springframework.beans.testfixture.beans;
import org.springframework.lang.Nullable;
/**
* @author Rob Harrop
* @since 2.0
@ -38,7 +40,7 @@ public class Pet {
}
@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.beans.testfixture.beans;
import java.io.Serializable;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
@ -63,7 +64,7 @@ public class SerializablePerson implements Person, Serializable {
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (!(other instanceof SerializablePerson p)) {
return false;
}

View File

@ -30,6 +30,7 @@ import java.util.Set;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
@ -464,7 +465,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}

View File

@ -256,7 +256,7 @@ final class BitsCronField extends CronField {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@ -77,7 +77,7 @@ final class CompositeCronField extends CronField {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

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

View File

@ -359,7 +359,7 @@ final class QuartzCronField extends CronField {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@ -1651,7 +1651,7 @@ public abstract class AbstractAopProxyTests {
public static class AllInstancesAreEqual implements IOther {
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return (other instanceof AllInstancesAreEqual);
}

View File

@ -35,6 +35,7 @@ import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@ -214,7 +215,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
return MethodMatcher.TRUE;
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
return true;
}
@Override

View File

@ -27,6 +27,7 @@ import org.springframework.aop.support.AopUtils;
import org.springframework.beans.testfixture.beans.IOther;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
@ -197,7 +198,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@ -37,6 +37,7 @@ import org.springframework.context.annotation6.Jsr330NamedForScanning;
import org.springframework.context.testfixture.context.annotation.CglibConfiguration;
import org.springframework.context.testfixture.context.annotation.LambdaBeanConfiguration;
import org.springframework.core.ResolvableType;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
import static java.lang.String.format;
@ -732,7 +733,7 @@ class TestBean {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}

View File

@ -18,6 +18,8 @@ package org.springframework.context.event.test;
import java.util.UUID;
import org.springframework.lang.Nullable;
/**
* @author Stephane Nicoll
*/
@ -35,7 +37,7 @@ public abstract class AbstractIdentifiable implements Identifiable {
}
@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.context.event.test;
import org.springframework.core.ResolvableType;
import org.springframework.core.ResolvableTypeProvider;
import org.springframework.lang.Nullable;
/**
* A simple POJO that implements {@link ResolvableTypeProvider}.
@ -37,7 +38,7 @@ public class GenericEventPojo<T> implements ResolvableTypeProvider {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@ -19,6 +19,7 @@ package org.springframework.context.event.test;
import java.util.UUID;
import org.springframework.context.ApplicationEvent;
import org.springframework.lang.Nullable;
/**
* A basic test event that can be uniquely identified easily.
@ -49,7 +50,7 @@ public abstract class IdentifiableApplicationEvent extends ApplicationEvent impl
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@ -25,6 +25,8 @@ import javax.management.MBeanInfo;
import javax.management.MBeanNotificationInfo;
import javax.management.MBeanOperationInfo;
import org.springframework.lang.Nullable;
/**
* @author Rob Harrop
* @author Juergen Hoeller
@ -76,7 +78,7 @@ public class TestDynamicMBean implements DynamicMBean {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
return (obj instanceof TestDynamicMBean);
}

View File

@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
@ -288,7 +289,7 @@ public class ModelMapTests {
public static class SomeInnerClass {
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
return (obj instanceof SomeInnerClass);
}

View File

@ -16,6 +16,7 @@
package org.springframework.context.testfixture.cache.beans;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
@ -41,16 +42,11 @@ public class TestEntity {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (obj == this) {
return true;
}
if (obj == null) {
return false;
}
if (obj instanceof TestEntity) {
return ObjectUtils.nullSafeEquals(this.id, ((TestEntity) obj).id);
}
return false;
return (obj instanceof TestEntity that && ObjectUtils.nullSafeEquals(this.id, that.id));
}
}

View File

@ -18,6 +18,8 @@ package org.springframework.aot.agent;
import java.util.Objects;
import org.springframework.lang.Nullable;
/**
* Reference to a Java method, identified by its owner class and the method name.
*
@ -61,7 +63,7 @@ public final class MethodReference {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@ -117,7 +117,7 @@ public final class ClassFiles implements Iterable<ClassFile> {
}
@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.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@ -81,7 +82,7 @@ public abstract sealed class DynamicFile permits SourceFile, ResourceFile {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}

View File

@ -102,7 +102,7 @@ final class DynamicFiles<F extends DynamicFile> implements Iterable<F> {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}

View File

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

View File

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

View File

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

View File

@ -83,7 +83,7 @@ public abstract class AbstractTypeReference implements TypeReference {
}
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}

View File

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

View File

@ -77,7 +77,7 @@ public final class JdkProxyHint implements ConditionalHint {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@ -56,7 +56,7 @@ public final class ResourceBundleHint implements ConditionalHint {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@ -98,7 +98,7 @@ public final class ResourcePatternHint implements ConditionalHint {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@ -287,7 +287,7 @@ public final class TypeHint implements ConditionalHint {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

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

View File

@ -125,7 +125,7 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
return this == obj || this.delegate.equals(obj);
}
@ -362,7 +362,7 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
@ -508,7 +508,7 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
@ -625,7 +625,7 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
return this == obj || this.delegate.equals(obj);
}

View File

@ -49,6 +49,7 @@ import org.springframework.core.convert.ConversionFailedException;
import org.springframework.core.convert.ConverterNotFoundException;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
import static org.assertj.core.api.Assertions.assertThat;
@ -1045,7 +1046,7 @@ class DefaultConversionServiceTests {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (!(o instanceof SSN ssn)) {
return false;
}
@ -1085,7 +1086,7 @@ class DefaultConversionServiceTests {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (!(o instanceof ISBN isbn)) {
return false;
}

View File

@ -26,6 +26,7 @@ import org.springframework.core.testfixture.EnabledForTestGroups;
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.core.testfixture.TestGroup.LONG_RUNNING;
@ -56,7 +57,7 @@ class CachingMetadataReaderLeakTests {
Resource resource = new UrlResource(url) {
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
return (obj == this);
}

View File

@ -29,6 +29,8 @@ import java.util.Set;
import org.junit.jupiter.api.Test;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;
/**
@ -219,7 +221,7 @@ class CollectionUtilsTests {
}
@Override
public boolean equals(Object rhs) {
public boolean equals(@Nullable Object rhs) {
if (this == rhs) {
return true;
}

View File

@ -43,6 +43,7 @@ import org.xml.sax.helpers.AttributesImpl;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.lang.Nullable;
import org.springframework.tests.MockitoUtils;
import org.springframework.tests.MockitoUtils.InvocationArgumentsAdapter;
@ -261,7 +262,7 @@ abstract class AbstractStaxXMLReaderTests {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
Attributes other = ((PartialAttributes) obj).attributes;
if (this.attributes.getLength() != other.getLength()) {
return false;

View File

@ -18,6 +18,8 @@ package org.springframework.core.testfixture.security;
import java.security.Principal;
import org.springframework.lang.Nullable;
/**
* An implementation of {@link Principal} for testing.
*
@ -37,7 +39,7 @@ public class TestPrincipal implements Principal {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (obj == this) {
return true;
}

View File

@ -2251,7 +2251,7 @@ class SpelReproTests extends AbstractExpressionTests {
}
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof TestClass2 &&
this.string.equals(((TestClass2) other).string)));
}

View File

@ -16,6 +16,8 @@
package org.springframework.expression.spel.testresources;
import org.springframework.lang.Nullable;
///CLOVER:OFF
public class PlaceOfBirth {
@ -51,7 +53,7 @@ public class PlaceOfBirth {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (!(o instanceof PlaceOfBirth otherPOB)) {
return false;
}

View File

@ -33,6 +33,7 @@ import org.junit.jupiter.api.Test;
import org.mockito.stubbing.Answer;
import org.springframework.core.MethodParameter;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
@ -276,7 +277,7 @@ class MappingJackson2MessageConverterTests {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@ -19,6 +19,8 @@ package org.springframework.messaging.simp.user;
import java.util.HashSet;
import java.util.Set;
import org.springframework.lang.Nullable;
/**
* @author Rossen Stoyanchev
*/
@ -64,8 +66,8 @@ public class TestSimpSession implements SimpSession {
@Override
public boolean equals(Object other) {
return (this == other || (other instanceof SimpSession && this.id.equals(((SimpSession) other).getId())));
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof SimpSession that && this.id.equals(that.getId())));
}
@Override

View File

@ -16,6 +16,7 @@
package org.springframework.messaging.simp.user;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
@ -57,7 +58,7 @@ public class TestSimpSubscription implements SimpSubscription {
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}

View File

@ -74,7 +74,7 @@ public class TestSimpUser implements SimpUser {
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof SimpUser && this.name.equals(((SimpUser) other).getName())));
}

View File

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

View File

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

View File

@ -26,6 +26,7 @@ import java.util.function.Supplier;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.lang.Nullable;
import org.springframework.test.context.ContextCustomizer;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
@ -96,7 +97,7 @@ class DynamicPropertiesContextCustomizer implements ContextCustomizer {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}

View File

@ -190,7 +190,7 @@ public class XpathAssertions {
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
throw new AssertionError("Object#equals is disabled " +
"to avoid being used in error instead of XPathAssertions#isEqualTo(String).");
}

View File

@ -19,6 +19,7 @@ package org.springframework.test.web;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
@XmlRootElement
@ -66,7 +67,7 @@ public class Person {
}
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}

View File

@ -20,6 +20,8 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.springframework.lang.Nullable;
@XmlRootElement
class Person {
@ -44,7 +46,7 @@ class Person {
}
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}

View File

@ -19,6 +19,7 @@ package org.springframework.http;
import java.io.Serializable;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
/**
* Default implementation of {@link HttpStatusCode}.
@ -89,7 +90,7 @@ final class DefaultHttpStatusCode
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
return (this == obj) || (obj instanceof HttpStatusCode that && this.value == that.value());
}

View File

@ -170,7 +170,7 @@ public final class HttpMethod implements Comparable<HttpMethod>, Serializable {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
return (this == obj) || (obj instanceof HttpMethod that && this.name.equals(that.name));
}

View File

@ -743,7 +743,7 @@ public class CorsConfiguration {
}
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}

View File

@ -41,6 +41,7 @@ import org.springframework.http.codec.xml.jaxb.XmlRootElementWithNameAndNamespac
import org.springframework.http.codec.xml.jaxb.XmlType;
import org.springframework.http.codec.xml.jaxb.XmlTypeWithName;
import org.springframework.http.codec.xml.jaxb.XmlTypeWithNameAndNamespace;
import org.springframework.lang.Nullable;
import org.springframework.util.MimeType;
import org.springframework.web.testfixture.xml.Pojo;
@ -308,7 +309,7 @@ public class Jaxb2XmlDecoderTests extends AbstractLeakCheckingTests {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@ -35,6 +35,7 @@ import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.lang.Nullable;
import org.springframework.web.testfixture.http.MockHttpInputMessage;
import static org.assertj.core.api.Assertions.assertThat;
@ -221,7 +222,7 @@ public class Jaxb2CollectionHttpMessageConverterTests {
public String external;
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
@ -252,7 +253,7 @@ public class Jaxb2CollectionHttpMessageConverterTests {
public String s = "Hello World";
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@ -18,6 +18,8 @@ package org.springframework.web.testfixture.xml;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.springframework.lang.Nullable;
/**
* @author Sebastien Deleuze
*/
@ -53,7 +55,7 @@ public class Pojo {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@ -31,6 +31,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.server.reactive.HttpHandler;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@ -266,7 +267,7 @@ class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTe
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@ -27,6 +27,7 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.lang.Nullable;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer;
@ -137,7 +138,7 @@ class PublisherHandlerFunctionIntegrationTests extends AbstractRouterFunctionInt
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@ -25,6 +25,7 @@ import reactor.test.StepVerifier;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.MediaType;
import org.springframework.http.codec.ServerSentEvent;
import org.springframework.lang.Nullable;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer;
@ -166,7 +167,7 @@ class SseHandlerFunctionIntegrationTests extends AbstractRouterFunctionIntegrati
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@ -26,6 +26,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.server.reactive.HttpHandler;
import org.springframework.lang.Nullable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.DispatcherHandler;
@ -144,7 +145,7 @@ class JacksonStreamingIntegrationTests extends AbstractHttpHandlerIntegrationTes
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

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

View File

@ -49,6 +49,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
import org.springframework.lang.Nullable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -703,7 +704,7 @@ class RequestMappingMessageConversionIntegrationTests extends AbstractRequestMap
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@ -42,6 +42,7 @@ import org.springframework.http.client.reactive.JettyClientHttpConnector;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.http.codec.ServerSentEvent;
import org.springframework.http.server.reactive.HttpHandler;
import org.springframework.lang.Nullable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -268,7 +269,7 @@ class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@ -18,6 +18,8 @@ package org.springframework.web.servlet.tags.form;
import java.beans.PropertyEditorSupport;
import org.springframework.lang.Nullable;
/**
* @author Juergen Hoeller
*/
@ -42,7 +44,7 @@ public class ItemPet {
}
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}

View File

@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.propertyeditors.StringArrayPropertyEditor;
import org.springframework.beans.testfixture.beans.Colour;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils;
import org.springframework.validation.BeanPropertyBindingResult;
import org.springframework.web.servlet.support.BindStatus;
@ -555,7 +556,7 @@ class OptionTagTests extends AbstractHtmlElementTagTests {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (obj instanceof RulesVariant other) {
return this.toId().equals(other.toId());
}

View File

@ -34,6 +34,7 @@ import org.springframework.core.convert.ConverterNotFoundException;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.lang.Nullable;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.socket.ContextLoaderTestUtils;
@ -232,11 +233,8 @@ public class ConvertingEncoderDecoderSupportTests {
}
@Override
public boolean equals(Object obj) {
if (obj instanceof MyType) {
return ((MyType)obj).value.equals(value);
}
return false;
public boolean equals(@Nullable Object obj) {
return (obj instanceof MyType that && this.value.equals(that.value));
}
}