Merge branch '6.0.x'

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

View File

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

View File

@ -109,8 +109,8 @@ public abstract class ClassFilters {
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof UnionClassFilter that &&
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof UnionClassFilter that &&
ObjectUtils.nullSafeEquals(this.filters, that.filters)));
}
@ -150,8 +150,8 @@ public abstract class ClassFilters {
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof IntersectionClassFilter that &&
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof IntersectionClassFilter that &&
ObjectUtils.nullSafeEquals(this.filters, that.filters)));
}

View File

@ -100,8 +100,8 @@ public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut impleme
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof NameMatchMethodPointcut that &&
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof NameMatchMethodPointcut that &&
this.mappedNames.equals(that.mappedNames)));
}

View File

@ -46,8 +46,8 @@ public class RootClassFilter implements ClassFilter, Serializable {
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof RootClassFilter that &&
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof RootClassFilter that &&
this.clazz.equals(that.clazz)));
}

View File

@ -47,14 +47,8 @@ public class NopInterceptor implements MethodInterceptor {
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof NopInterceptor that)) {
return false;
}
return this.count == that.count;
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof NopInterceptor that && this.count == that.count));
}
@Override

View File

@ -338,8 +338,8 @@ class ExtendedBeanInfo implements BeanInfo {
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof PropertyDescriptor that &&
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof PropertyDescriptor that &&
PropertyDescriptorUtils.equals(this, that)));
}

View File

@ -366,8 +366,8 @@ public class MutablePropertyValues implements PropertyValues, Serializable {
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof MutablePropertyValues that &&
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof MutablePropertyValues that &&
this.propertyValueList.equals(that.propertyValueList)));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 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.
@ -52,8 +52,8 @@ public final class AutowiredPropertyMarker implements Serializable {
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj);
public boolean equals(@Nullable Object other) {
return (this == other);
}
@Override

View File

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

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 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.
@ -40,8 +40,8 @@ final class NullBean {
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || obj == null);
public boolean equals(@Nullable Object other) {
return (this == other || other == null);
}
@Override

View File

@ -61,9 +61,8 @@ public class SimpleKey implements Serializable {
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj ||
(obj instanceof SimpleKey that && Arrays.deepEquals(this.params, that.params)));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof SimpleKey that && Arrays.deepEquals(this.params, that.params)));
}
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 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.
@ -50,8 +50,8 @@ public final class NullValue implements Serializable {
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || obj == null);
public boolean equals(@Nullable Object other) {
return (this == other || other == null);
}
@Override

View File

@ -39,6 +39,7 @@ final class BeanMethod extends ConfigurationMethod {
super(metadata, configurationClass);
}
@Override
public void validate(ProblemReporter problemReporter) {
if (getMetadata().isStatic()) {
@ -55,9 +56,8 @@ final class BeanMethod extends ConfigurationMethod {
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj ||
(obj instanceof BeanMethod that && this.metadata.equals(that.metadata)));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof BeanMethod that && this.metadata.equals(that.metadata)));
}
@Override
@ -70,6 +70,7 @@ final class BeanMethod extends ConfigurationMethod {
return "BeanMethod: " + this.metadata;
}
private class NonOverridableMethodError extends Problem {
NonOverridableMethodError() {

View File

@ -237,8 +237,8 @@ final class ConfigurationClass {
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof ConfigurationClass that &&
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof ConfigurationClass that &&
getMetadata().getClassName().equals(that.getMetadata().getClassName())));
}

View File

@ -211,8 +211,8 @@ class ConfigurationClassParser {
}
List<PropertySourceDescriptor> getPropertySourceDescriptors() {
return (this.propertySourceRegistry != null ? this.propertySourceRegistry.getDescriptors()
: Collections.emptyList());
return (this.propertySourceRegistry != null ? this.propertySourceRegistry.getDescriptors() :
Collections.emptyList());
}
protected void processConfigurationClass(ConfigurationClass configClass, Predicate<String> filter) throws IOException {
@ -1005,8 +1005,8 @@ class ConfigurationClassParser {
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof SourceClass that &&
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof SourceClass that &&
this.metadata.getClassName().equals(that.metadata.getClassName())));
}

View File

@ -61,6 +61,7 @@ public final class ClassFiles implements Iterable<ClassFile> {
return none().and(ClassFiles);
}
/**
* Return a new {@link ClassFiles} instance that merges classes from
* another array of {@link ClassFile} instances.
@ -116,15 +117,10 @@ public final class ClassFiles implements Iterable<ClassFile> {
return this.files.get(name);
}
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
return this.files.equals(((ClassFiles) obj).files);
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof ClassFiles that && this.files.equals(that.files)));
}
@Override

View File

@ -18,7 +18,6 @@ package org.springframework.core.test.tools;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
@ -81,22 +80,16 @@ public abstract sealed class DynamicFile permits SourceFile, ResourceFile {
return this.path;
}
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
DynamicFile other = (DynamicFile) obj;
return Objects.equals(this.path, other.path)
&& Objects.equals(this.content, other.content);
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof DynamicFile that &&
this.path.equals(that.path) && this.content.equals(that.content)));
}
@Override
public int hashCode() {
return Objects.hash(this.path, this.content);
return this.path.hashCode();
}
@Override

View File

@ -39,7 +39,6 @@ final class DynamicFiles<F extends DynamicFile> implements Iterable<F> {
private static final DynamicFiles<?> NONE = new DynamicFiles<>(Collections.emptyMap());
private final Map<String, F> files;
@ -101,15 +100,10 @@ final class DynamicFiles<F extends DynamicFile> implements Iterable<F> {
return files.iterator().next();
}
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
return this.files.equals(((DynamicFiles<?>) obj).files);
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof DynamicFiles<?> that && this.files.equals(that.files)));
}
@Override

View File

@ -130,15 +130,10 @@ public final class ResourceFiles implements Iterable<ResourceFile> {
return this.files.getSingle();
}
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
return this.files.equals(((ResourceFiles) obj).files);
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof ResourceFiles that && this.files.equals(that.files)));
}
@Override

View File

@ -17,7 +17,6 @@
package org.springframework.core.test.tools;
import java.util.Iterator;
import java.util.Objects;
import java.util.regex.Pattern;
import java.util.stream.Stream;
@ -155,19 +154,14 @@ public final class SourceFiles implements Iterable<SourceFile> {
* one file
*/
public SourceFile getSingleFromPackage(String packageName) {
return this.files.getSingle(candidate -> Objects.equals(packageName,
ClassUtils.getPackageName(candidate.getClassName())));
return this.files.getSingle(candidate ->
ClassUtils.getPackageName(candidate.getClassName()).equals(packageName));
}
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
return this.files.equals(((SourceFiles) obj).files);
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof SourceFiles that && this.files.equals(that.files)));
}
@Override

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

View File

@ -333,8 +333,8 @@ public class MessageHeaders implements Map<String, Object>, Serializable {
// equals, hashCode, toString
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof MessageHeaders that && this.headers.equals(that.headers)));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof MessageHeaders that && this.headers.equals(that.headers)));
}
@Override

View File

@ -77,8 +77,8 @@ public class SimpMessageMappingInfo implements MessageCondition<SimpMessageMappi
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj) || (obj instanceof SimpMessageMappingInfo that && this.delegate.equals(that.delegate));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof SimpMessageMappingInfo that && this.delegate.equals(that.delegate)));
}
@Override

View File

@ -481,8 +481,8 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof Subscription that && this.id.equals(that.id)));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof Subscription that && this.id.equals(that.id)));
}
@Override

View File

@ -555,8 +555,8 @@ public class StompHeaders implements MultiValueMap<String, String>, Serializable
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof StompHeaders that && this.headers.equals(that.headers)));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof StompHeaders that && this.headers.equals(that.headers)));
}
@Override

View File

@ -369,8 +369,8 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof SimpUser that && this.name.equals(that.getName())));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof SimpUser that && this.name.equals(that.getName())));
}
@Override
@ -455,8 +455,8 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof SimpSession that && this.id.equals(that.getId())));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof SimpSession that && this.id.equals(that.getId())));
}
@Override

View File

@ -43,10 +43,9 @@ public class SpringFlushSynchronization implements TransactionSynchronization {
SessionFactoryUtils.flush(this.session, false);
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof SpringFlushSynchronization that && this.session == that.session));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof SpringFlushSynchronization that && this.session == that.session));
}
@Override

View File

@ -47,7 +47,6 @@ class DynamicPropertiesContextCustomizer implements ContextCustomizer {
private static final String PROPERTY_SOURCE_NAME = "Dynamic Test Properties";
private final Set<Method> methods;
@ -66,9 +65,7 @@ class DynamicPropertiesContextCustomizer implements ContextCustomizer {
}
@Override
public void customizeContext(ConfigurableApplicationContext context,
MergedContextConfiguration mergedConfig) {
public void customizeContext(ConfigurableApplicationContext context, MergedContextConfiguration mergedConfig) {
MutablePropertySources sources = context.getEnvironment().getPropertySources();
sources.addFirst(new DynamicValuesPropertySource(PROPERTY_SOURCE_NAME, buildDynamicPropertiesMap()));
}
@ -91,20 +88,16 @@ class DynamicPropertiesContextCustomizer implements ContextCustomizer {
return this.methods;
}
@Override
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof DynamicPropertiesContextCustomizer that &&
this.methods.equals(that.methods)));
}
@Override
public int hashCode() {
return this.methods.hashCode();
}
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
return this.methods.equals(((DynamicPropertiesContextCustomizer) obj).methods);
}
}

View File

@ -27,8 +27,7 @@ import org.springframework.lang.Nullable;
* @author Arjen Poutsma
* @since 6.0
*/
final class DefaultHttpStatusCode
implements HttpStatusCode, Comparable<HttpStatusCode>, Serializable {
final class DefaultHttpStatusCode implements HttpStatusCode, Comparable<HttpStatusCode>, Serializable {
private static final long serialVersionUID = 7017664779360718111L;
@ -79,21 +78,22 @@ final class DefaultHttpStatusCode
return this.value / 100;
}
@Override
public int compareTo(@NonNull HttpStatusCode o) {
return Integer.compare(this.value, o.value());
}
@Override
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof HttpStatusCode that && this.value == that.value()));
}
@Override
public int hashCode() {
return this.value;
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj) || (obj instanceof HttpStatusCode that && this.value == that.value());
}
@Override
public String toString() {
return Integer.toString(this.value);

View File

@ -1834,21 +1834,8 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof HttpHeaders other)) {
return false;
}
return unwrap(this).equals(unwrap(other));
}
private static MultiValueMap<String, String> unwrap(HttpHeaders headers) {
while (headers.headers instanceof HttpHeaders httpHeaders) {
headers = httpHeaders;
}
return headers.headers;
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof HttpHeaders that && unwrap(this).equals(unwrap(that))));
}
@Override
@ -1955,6 +1942,14 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
return new String(encodedBytes, charset);
}
private static MultiValueMap<String, String> unwrap(HttpHeaders headers) {
while (headers.headers instanceof HttpHeaders httpHeaders) {
headers = httpHeaders;
}
return headers.headers;
}
// Package-private: used in ResponseCookie
static String formatDate(long date) {
Instant instant = Instant.ofEpochMilli(date);

View File

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

View File

@ -74,8 +74,8 @@ final class DefaultPathContainer implements PathContainer {
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj) || (obj instanceof PathContainer that && value().equals(that.value()));
public boolean equals(@Nullable Object other) {
return (this == other) || (other instanceof PathContainer that && value().equals(that.value()));
}
@Override
@ -281,8 +281,8 @@ final class DefaultPathContainer implements PathContainer {
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj) || (obj instanceof PathSegment that && value().equals(that.value()));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof PathSegment that && this.value.equals(that.value())));
}
@Override

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.
@ -88,9 +88,9 @@ class MultipartFileResource extends AbstractResource {
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof MultipartFileResource other &&
this.multipartFile.equals(other.multipartFile)));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof MultipartFileResource that &&
this.multipartFile.equals(that.multipartFile)));
}
@Override