Merge branch '6.0.x'

This commit is contained in:
Juergen Hoeller
2023-08-04 02:40:17 +02:00
56 changed files with 198 additions and 288 deletions

View File

@@ -91,19 +91,13 @@ final class MethodName {
@Override
public int hashCode() {
return this.value.hashCode();
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof MethodName that && this.value.equals(that.value)));
}
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if ((obj == null) || (getClass() != obj.getClass())) {
return false;
}
return this.value.equals(((MethodName) obj).value);
public int hashCode() {
return this.value.hashCode();
}
@Override
@@ -111,6 +105,7 @@ final class MethodName {
return (!StringUtils.hasLength(this.value)) ? "$$aot" : this.value ;
}
private static String join(String[] parts) {
return StringUtils.uncapitalize(Arrays.stream(parts).map(MethodName::clean)
.map(StringUtils::capitalize).collect(Collectors.joining()));

View File

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

View File

@@ -14,7 +14,6 @@
* limitations under the License.
*/
package org.springframework.core;
import java.lang.reflect.ParameterizedType;
@@ -67,8 +66,8 @@ public abstract class ParameterizedTypeReference<T> {
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof ParameterizedTypeReference<?> that && this.type.equals(that.type)));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof ParameterizedTypeReference<?> that && this.type.equals(that.type)));
}
@Override
@@ -91,8 +90,7 @@ public abstract class ParameterizedTypeReference<T> {
* @since 4.3.12
*/
public static <T> ParameterizedTypeReference<T> forType(Type type) {
return new ParameterizedTypeReference<>(type) {
};
return new ParameterizedTypeReference<>(type) {};
}
private static Class<?> findParameterizedTypeReferenceSubclass(Class<?> child) {

View File

@@ -779,8 +779,8 @@ public class TypeDescriptor implements Serializable {
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof AnnotatedElementAdapter that &&
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof AnnotatedElementAdapter that &&
Arrays.equals(this.annotations, that.annotations)));
}

View File

@@ -168,23 +168,14 @@ final class ProfilesParser {
}
@Override
public int hashCode() {
return this.expressions.hashCode();
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof ParsedProfiles that &&
this.expressions.equals(that.expressions)));
}
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
ParsedProfiles that = (ParsedProfiles) obj;
return this.expressions.equals(that.expressions);
public int hashCode() {
return this.expressions.hashCode();
}
@Override
@@ -198,7 +189,6 @@ final class ProfilesParser {
private String wrap(String str) {
return "(" + str + ")";
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -134,9 +134,9 @@ public abstract class PropertySource<T> {
* <p>No properties other than {@code name} are evaluated.
*/
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof PropertySource<?> other &&
ObjectUtils.nullSafeEquals(getName(), other.getName())));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof PropertySource<?> that &&
ObjectUtils.nullSafeEquals(getName(), that.getName())));
}
/**

View File

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

View File

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

View File

@@ -272,13 +272,10 @@ public class ClassPathResource extends AbstractFileResolvingResource {
* @see #getClassLoader()
*/
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
return (obj instanceof ClassPathResource that &&
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof ClassPathResource that &&
this.absolutePath.equals(that.absolutePath) &&
ObjectUtils.nullSafeEquals(getClassLoader(), that.getClassLoader()));
ObjectUtils.nullSafeEquals(getClassLoader(), that.getClassLoader())));
}
/**

View File

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

View File

@@ -395,8 +395,8 @@ public class FileSystemResource extends AbstractResource implements WritableReso
* @see #getPath()
*/
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof FileSystemResource that && this.path.equals(that.path)));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof FileSystemResource that && this.path.equals(that.path)));
}
/**

View File

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

View File

@@ -298,8 +298,8 @@ public class PathResource extends AbstractResource implements WritableResource {
* This implementation compares the underlying {@link Path} references.
*/
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof PathResource that && this.path.equals(that.path)));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof PathResource that && this.path.equals(that.path)));
}
/**

View File

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

View File

@@ -130,9 +130,8 @@ public class VfsResource extends AbstractResource {
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof VfsResource that &&
this.resource.equals(that.resource)));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof VfsResource that && this.resource.equals(that.resource)));
}
@Override

View File

@@ -337,8 +337,8 @@ public final class Netty5DataBuffer implements CloseableDataBuffer, TouchableDat
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof Netty5DataBuffer that && this.buffer.equals(that.buffer)));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof Netty5DataBuffer that && this.buffer.equals(that.buffer)));
}
@Override
@@ -362,7 +362,6 @@ public final class Netty5DataBuffer implements CloseableDataBuffer, TouchableDat
@Nullable
private T next;
public BufferComponentIterator(ComponentIterator<T> delegate, boolean readable) {
Assert.notNull(delegate, "Delegate must not be null");
this.delegate = delegate;

View File

@@ -363,8 +363,8 @@ public class NettyDataBuffer implements PooledDataBuffer {
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof NettyDataBuffer that && this.byteBuf.equals(that.byteBuf)));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof NettyDataBuffer that && this.byteBuf.equals(that.byteBuf)));
}
@Override
@@ -386,7 +386,6 @@ public class NettyDataBuffer implements PooledDataBuffer {
private int cursor = 0;
public ByteBufferIterator(ByteBuffer[] byteBuffers, boolean readOnly) {
this.byteBuffers = byteBuffers;
this.readOnly = readOnly;

View File

@@ -120,9 +120,10 @@ public class StandardClassMetadata implements ClassMetadata {
return StringUtils.toStringArray(memberClassNames);
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof StandardClassMetadata that &&
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof StandardClassMetadata that &&
getIntrospectedClass().equals(that.getIntrospectedClass())));
}

View File

@@ -149,9 +149,10 @@ public class StandardMethodMetadata implements MethodMetadata {
annotationName, classValuesAsString, false);
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof StandardMethodMetadata that &&
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof StandardMethodMetadata that &&
this.introspectedMethod.equals(that.introspectedMethod)));
}

View File

@@ -163,8 +163,8 @@ final class SimpleAnnotationMetadata implements AnnotationMetadata {
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof SimpleAnnotationMetadata that && this.className.equals(that.className)));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof SimpleAnnotationMetadata that && this.className.equals(that.className)));
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -164,6 +164,7 @@ final class SimpleAnnotationMetadataReadingVisitor extends ClassVisitor {
return (access & Opcodes.ACC_INTERFACE) != 0;
}
/**
* {@link MergedAnnotation} source.
*/
@@ -176,26 +177,19 @@ final class SimpleAnnotationMetadataReadingVisitor extends ClassVisitor {
}
@Override
public int hashCode() {
return this.className.hashCode();
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof Source that && this.className.equals(that.className)));
}
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
return this.className.equals(((Source) obj).className);
public int hashCode() {
return this.className.hashCode();
}
@Override
public String toString() {
return this.className;
}
}
}

View File

@@ -100,9 +100,10 @@ final class SimpleMethodMetadata implements MethodMetadata {
return this.annotations;
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof SimpleMethodMetadata that && this.source.equals(that.source)));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof SimpleMethodMetadata that && this.source.equals(that.source)));
}
@Override

View File

@@ -66,6 +66,7 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
this.delegate = (MultiValueMap<K, V>) delegate;
}
// delegation
@Override
@@ -92,7 +93,7 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
@Nullable
public List<V> get(Object key) {
List<V> result = this.delegate.get(key);
return result != null ? Collections.unmodifiableList(result) : null;
return (result != null ? Collections.unmodifiableList(result) : null);
}
@Override
@@ -119,21 +120,23 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
return this.delegate.toSingleValueMap();
}
@Override
public boolean equals(@Nullable Object other) {
return (this == other || this.delegate.equals(other));
}
@Override
public int hashCode() {
return this.delegate.hashCode();
}
@Override
public boolean equals(@Nullable Object obj) {
return this == obj || this.delegate.equals(obj);
}
@Override
public String toString() {
return this.delegate.toString();
}
// lazy init
@Override
@@ -239,20 +242,17 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
}
@Override
public List<V> computeIfPresent(K key,
BiFunction<? super K, ? super List<V>, ? extends List<V>> remappingFunction) {
public List<V> computeIfPresent(K key, BiFunction<? super K, ? super List<V>, ? extends List<V>> remappingFunction) {
throw new UnsupportedOperationException();
}
@Override
public List<V> compute(K key,
BiFunction<? super K, ? super List<V>, ? extends List<V>> remappingFunction) {
public List<V> compute(K key, BiFunction<? super K, ? super List<V>, ? extends List<V>> remappingFunction) {
throw new UnsupportedOperationException();
}
@Override
public List<V> merge(K key, List<V> value,
BiFunction<? super List<V>, ? super List<V>, ? extends List<V>> remappingFunction) {
public List<V> merge(K key, List<V> value, BiFunction<? super List<V>, ? super List<V>, ? extends List<V>> remappingFunction) {
throw new UnsupportedOperationException();
}
@@ -269,7 +269,6 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
@SuppressWarnings("serial")
private final Set<Entry<K, List<V>>> delegate;
@SuppressWarnings("unchecked")
public UnmodifiableEntrySet(Set<? extends Entry<? extends K, ? extends List<? extends V>>> delegate) {
this.delegate = (Set<Entry<K, List<V>>>) delegate;
@@ -357,20 +356,13 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
}
@Override
public int hashCode() {
return this.delegate.hashCode();
public boolean equals(@Nullable Object other) {
return (this == other || other instanceof Set<?> that && size() == that.size() && containsAll(that));
}
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
else if (obj instanceof Set<?> other) {
return other.size() == this.delegate.size() &&
containsAll(other);
}
return false;
public int hashCode() {
return this.delegate.hashCode();
}
@Override
@@ -420,10 +412,10 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
private final Spliterator<Entry<K, List<V>>> delegate;
@SuppressWarnings("unchecked")
public UnmodifiableEntrySpliterator(
Spliterator<? extends Entry<? extends K, ? extends List<? extends V>>> delegate) {
this.delegate = (Spliterator<Entry<K, List<V>>>) delegate;
}
@@ -480,7 +472,6 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
private final Entry<K, List<V>> delegate;
@SuppressWarnings("unchecked")
public UnmodifiableEntry(Entry<? extends K, ? extends List<? extends V>> delegate) {
Assert.notNull(delegate, "Delegate must not be null");
@@ -503,20 +494,14 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
}
@Override
public int hashCode() {
return this.delegate.hashCode();
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof Map.Entry<?, ?> that &&
getKey().equals(that.getKey()) && getValue().equals(that.getValue())));
}
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
else if (obj instanceof Map.Entry<?, ?> other) {
return getKey().equals(other.getKey()) &&
getValue().equals(other.getValue());
}
return false;
public int hashCode() {
return this.delegate.hashCode();
}
@Override
@@ -534,7 +519,6 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
@SuppressWarnings("serial")
private final Collection<List<V>> delegate;
public UnmodifiableValueCollection(Collection<List<V>> delegate) {
this.delegate = delegate;
}
@@ -620,13 +604,13 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
}
@Override
public int hashCode() {
return this.delegate.hashCode();
public boolean equals(@Nullable Object other) {
return (this == other || this.delegate.equals(other));
}
@Override
public boolean equals(@Nullable Object obj) {
return this == obj || this.delegate.equals(obj);
public int hashCode() {
return this.delegate.hashCode();
}
@Override
@@ -676,7 +660,6 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
private final Spliterator<List<T>> delegate;
public UnmodifiableValueSpliterator(Spliterator<List<T>> delegate) {
this.delegate = delegate;
}
@@ -728,6 +711,6 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
return this.delegate.getComparator();
}
}
}
}

View File

@@ -69,8 +69,8 @@ public class BooleanComparator implements Comparator<Boolean>, Serializable {
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof BooleanComparator that && this.trueLow == that.trueLow));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof BooleanComparator that && this.trueLow == that.trueLow));
}
@Override