Annotate Object#equals parameter with @Nullable

Closes gh-23093
This commit is contained in:
Sebastien Deleuze
2019-06-06 14:18:12 +02:00
parent 33becd8258
commit 098ac0bbb8
158 changed files with 222 additions and 176 deletions

View File

@@ -92,7 +92,7 @@ public abstract class AttributeAccessorSupport implements AttributeAccessor, Ser
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof AttributeAccessorSupport &&
this.attributes.equals(((AttributeAccessorSupport) other).attributes)));
}

View File

@@ -50,7 +50,7 @@ public final class MethodClassKey implements Comparable<MethodClassKey> {
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}

View File

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

View File

@@ -20,6 +20,7 @@ package org.springframework.core;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -66,7 +67,7 @@ public abstract class ParameterizedTypeReference<T> {
}
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof ParameterizedTypeReference &&
this.type.equals(((ParameterizedTypeReference<?>) other).type)));
}

View File

@@ -880,7 +880,7 @@ public class ResolvableType implements Serializable {
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
@@ -1549,7 +1549,7 @@ public class ResolvableType implements Serializable {
}
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}

View File

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

View File

@@ -452,7 +452,7 @@ public class TypeDescriptor implements Serializable {
}
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
@@ -778,7 +778,7 @@ public class TypeDescriptor implements Serializable {
}
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof AnnotatedElementAdapter &&
Arrays.equals(this.annotations, ((AnnotatedElementAdapter) other).annotations)));
}

View File

@@ -458,7 +458,7 @@ public class GenericConversionService implements ConfigurableConversionService {
}
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}

View File

@@ -132,7 +132,7 @@ public abstract class PropertySource<T> {
* <p>No properties other than {@code name} are evaluated.
*/
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof PropertySource &&
ObjectUtils.nullSafeEquals(this.name, ((PropertySource<?>) other).name)));
}

View File

@@ -215,7 +215,7 @@ public abstract class AbstractResource implements Resource {
* @see #getDescription()
*/
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof Resource &&
((Resource) other).getDescription().equals(getDescription())));
}

View File

@@ -115,7 +115,7 @@ public class ByteArrayResource extends AbstractResource {
* @see java.util.Arrays#equals(byte[], byte[])
*/
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof ByteArrayResource &&
Arrays.equals(((ByteArrayResource) other).byteArray, this.byteArray)));
}

View File

@@ -244,7 +244,7 @@ public class ClassPathResource extends AbstractFileResolvingResource {
* This implementation compares the underlying class path locations.
*/
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}

View File

@@ -72,7 +72,7 @@ public class DescriptiveResource extends AbstractResource {
* This implementation compares the underlying description String.
*/
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof DescriptiveResource &&
((DescriptiveResource) other).description.equals(this.description)));
}

View File

@@ -335,7 +335,7 @@ public class FileSystemResource extends AbstractResource implements WritableReso
* This implementation compares the underlying File references.
*/
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof FileSystemResource &&
this.path.equals(((FileSystemResource) other).path)));
}

View File

@@ -115,7 +115,7 @@ public class InputStreamResource extends AbstractResource {
* This implementation compares the underlying InputStream.
*/
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof InputStreamResource &&
((InputStreamResource) other).inputStream.equals(this.inputStream)));
}

View File

@@ -32,6 +32,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -275,7 +276,7 @@ public class PathResource extends AbstractResource implements WritableResource {
* This implementation compares the underlying Path references.
*/
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof PathResource &&
this.path.equals(((PathResource) other).path)));
}

View File

@@ -263,7 +263,7 @@ public class UrlResource extends AbstractFileResolvingResource {
* This implementation compares the underlying URL references.
*/
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof UrlResource &&
this.cleanedUrl.equals(((UrlResource) other).cleanedUrl)));
}

View File

@@ -23,6 +23,7 @@ import java.net.URI;
import java.net.URL;
import org.springframework.core.NestedIOException;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -130,7 +131,7 @@ public class VfsResource extends AbstractResource {
}
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof VfsResource &&
this.resource.equals(((VfsResource) other).resource)));
}

View File

@@ -24,6 +24,7 @@ import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.function.IntPredicate;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -411,7 +412,7 @@ public class DefaultDataBuffer implements DataBuffer {
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}

View File

@@ -28,6 +28,7 @@ import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream;
import io.netty.buffer.ByteBufUtil;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -309,7 +310,7 @@ public class NettyDataBuffer implements PooledDataBuffer {
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof NettyDataBuffer &&
this.byteBuf.equals(((NettyDataBuffer) other).byteBuf)));
}

View File

@@ -161,7 +161,7 @@ public class EncodedResource implements InputStreamSource {
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}

View File

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

View File

@@ -127,7 +127,7 @@ final class SimpleMethodMetadataReadingVisitor extends MethodVisitor {
}
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}

View File

@@ -25,6 +25,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import org.springframework.lang.Nullable;
/**
* Simple {@link List} wrapper class that allows for elements to be
* automatically populated as they are requested. This is particularly
@@ -231,7 +233,7 @@ public class AutoPopulatingList<E> implements List<E>, Serializable {
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return this.backingList.equals(other);
}

View File

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

View File

@@ -758,7 +758,7 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen
@Override
@SuppressWarnings("rawtypes")
public final boolean equals(Object other) {
public final boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}

View File

@@ -273,7 +273,7 @@ public class LinkedCaseInsensitiveMap<V> implements Map<String, V>, Serializable
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
return this.targetMap.equals(obj);
}

View File

@@ -225,7 +225,7 @@ public class LinkedMultiValueMap<K, V> implements MultiValueMap<K, V>, Serializa
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
return this.targetMap.equals(obj);
}

View File

@@ -420,7 +420,7 @@ public class MimeType implements Comparable<MimeType>, Serializable {
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}

View File

@@ -19,6 +19,8 @@ package org.springframework.util.comparator;
import java.io.Serializable;
import java.util.Comparator;
import org.springframework.lang.Nullable;
/**
* A {@link Comparator} for {@link Boolean} objects that can sort either
* {@code true} or {@code false} first.
@@ -67,7 +69,7 @@ public class BooleanComparator implements Comparator<Boolean>, Serializable {
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof BooleanComparator &&
this.trueLow == ((BooleanComparator) other).trueLow));
}

View File

@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -187,7 +188,7 @@ public class CompoundComparator<T> implements Comparator<T>, Serializable {
@Override
@SuppressWarnings("unchecked")
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof CompoundComparator &&
this.comparators.equals(((CompoundComparator<T>) other).comparators)));
}

View File

@@ -19,6 +19,7 @@ package org.springframework.util.comparator;
import java.io.Serializable;
import java.util.Comparator;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -108,7 +109,7 @@ public class InvertibleComparator<T> implements Comparator<T>, Serializable {
@Override
@SuppressWarnings("unchecked")
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}

View File

@@ -108,7 +108,7 @@ public class NullSafeComparator<T> implements Comparator<T> {
@Override
@SuppressWarnings("unchecked")
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}

View File

@@ -236,7 +236,7 @@ public final class DataSize implements Comparable<DataSize> {
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}