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

@@ -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;
}