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

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