Browse Source

Consistent equals/hashCode style (and related polishing)

pull/31496/head
Juergen Hoeller 2 years ago
parent
commit
18966d048c
  1. 4
      spring-aop/src/main/java/org/springframework/aop/aspectj/TypePatternClassFilter.java
  2. 8
      spring-aop/src/main/java/org/springframework/aop/support/ClassFilters.java
  3. 4
      spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcut.java
  4. 4
      spring-aop/src/main/java/org/springframework/aop/support/RootClassFilter.java
  5. 10
      spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/interceptor/NopInterceptor.java
  6. 4
      spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java
  7. 4
      spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java
  8. 6
      spring-beans/src/main/java/org/springframework/beans/factory/config/AutowiredPropertyMarker.java
  9. 4
      spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionResource.java
  10. 6
      spring-beans/src/main/java/org/springframework/beans/factory/support/NullBean.java
  11. 5
      spring-context/src/main/java/org/springframework/cache/interceptor/SimpleKey.java
  12. 6
      spring-context/src/main/java/org/springframework/cache/support/NullValue.java
  13. 7
      spring-context/src/main/java/org/springframework/context/annotation/BeanMethod.java
  14. 4
      spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClass.java
  15. 8
      spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java
  16. 12
      spring-core-test/src/main/java/org/springframework/core/test/tools/ClassFiles.java
  17. 17
      spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicFile.java
  18. 12
      spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicFiles.java
  19. 11
      spring-core-test/src/main/java/org/springframework/core/test/tools/ResourceFiles.java
  20. 16
      spring-core-test/src/main/java/org/springframework/core/test/tools/SourceFiles.java
  21. 15
      spring-core/src/main/java/org/springframework/aot/generate/MethodName.java
  22. 4
      spring-core/src/main/java/org/springframework/core/AttributeAccessorSupport.java
  23. 8
      spring-core/src/main/java/org/springframework/core/ParameterizedTypeReference.java
  24. 4
      spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java
  25. 20
      spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java
  26. 8
      spring-core/src/main/java/org/springframework/core/env/PropertySource.java
  27. 4
      spring-core/src/main/java/org/springframework/core/io/AbstractResource.java
  28. 4
      spring-core/src/main/java/org/springframework/core/io/ByteArrayResource.java
  29. 9
      spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java
  30. 4
      spring-core/src/main/java/org/springframework/core/io/DescriptiveResource.java
  31. 4
      spring-core/src/main/java/org/springframework/core/io/FileSystemResource.java
  32. 4
      spring-core/src/main/java/org/springframework/core/io/InputStreamResource.java
  33. 4
      spring-core/src/main/java/org/springframework/core/io/PathResource.java
  34. 4
      spring-core/src/main/java/org/springframework/core/io/UrlResource.java
  35. 5
      spring-core/src/main/java/org/springframework/core/io/VfsResource.java
  36. 5
      spring-core/src/main/java/org/springframework/core/io/buffer/Netty5DataBuffer.java
  37. 5
      spring-core/src/main/java/org/springframework/core/io/buffer/NettyDataBuffer.java
  38. 5
      spring-core/src/main/java/org/springframework/core/type/StandardClassMetadata.java
  39. 5
      spring-core/src/main/java/org/springframework/core/type/StandardMethodMetadata.java
  40. 4
      spring-core/src/main/java/org/springframework/core/type/classreading/SimpleAnnotationMetadata.java
  41. 18
      spring-core/src/main/java/org/springframework/core/type/classreading/SimpleAnnotationMetadataReadingVisitor.java
  42. 5
      spring-core/src/main/java/org/springframework/core/type/classreading/SimpleMethodMetadata.java
  43. 69
      spring-core/src/main/java/org/springframework/util/UnmodifiableMultiValueMap.java
  44. 4
      spring-core/src/main/java/org/springframework/util/comparator/BooleanComparator.java
  45. 4
      spring-messaging/src/main/java/org/springframework/messaging/MessageHeaders.java
  46. 4
      spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessageMappingInfo.java
  47. 4
      spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java
  48. 4
      spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaders.java
  49. 8
      spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java
  50. 5
      spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringFlushSynchronization.java
  51. 21
      spring-test/src/main/java/org/springframework/test/context/support/DynamicPropertiesContextCustomizer.java
  52. 12
      spring-web/src/main/java/org/springframework/http/DefaultHttpStatusCode.java
  53. 25
      spring-web/src/main/java/org/springframework/http/HttpHeaders.java
  54. 4
      spring-web/src/main/java/org/springframework/http/HttpMethod.java
  55. 8
      spring-web/src/main/java/org/springframework/http/server/DefaultPathContainer.java
  56. 8
      spring-web/src/main/java/org/springframework/web/multipart/MultipartFileResource.java

4
spring-aop/src/main/java/org/springframework/aop/aspectj/TypePatternClassFilter.java

@ -117,8 +117,8 @@ public class TypePatternClassFilter implements ClassFilter { @@ -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)));
}

8
spring-aop/src/main/java/org/springframework/aop/support/ClassFilters.java

@ -109,8 +109,8 @@ public abstract class ClassFilters { @@ -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 { @@ -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)));
}

4
spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcut.java

@ -100,8 +100,8 @@ public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut impleme @@ -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)));
}

4
spring-aop/src/main/java/org/springframework/aop/support/RootClassFilter.java

@ -46,8 +46,8 @@ public class RootClassFilter implements ClassFilter, Serializable { @@ -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)));
}

10
spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/interceptor/NopInterceptor.java

@ -47,14 +47,8 @@ public class NopInterceptor implements MethodInterceptor { @@ -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

4
spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java

@ -338,8 +338,8 @@ class ExtendedBeanInfo implements BeanInfo { @@ -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)));
}

4
spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java

@ -366,8 +366,8 @@ public class MutablePropertyValues implements PropertyValues, Serializable { @@ -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)));
}

6
spring-beans/src/main/java/org/springframework/beans/factory/config/AutowiredPropertyMarker.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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

4
spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionResource.java

@ -81,8 +81,8 @@ class BeanDefinitionResource extends AbstractResource { @@ -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)));
}

6
spring-beans/src/main/java/org/springframework/beans/factory/support/NullBean.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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

5
spring-context/src/main/java/org/springframework/cache/interceptor/SimpleKey.java vendored

@ -61,9 +61,8 @@ public class SimpleKey implements Serializable { @@ -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

6
spring-context/src/main/java/org/springframework/cache/support/NullValue.java vendored

@ -1,5 +1,5 @@ @@ -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 { @@ -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

7
spring-context/src/main/java/org/springframework/context/annotation/BeanMethod.java

@ -39,6 +39,7 @@ final class BeanMethod extends ConfigurationMethod { @@ -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 { @@ -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 { @@ -70,6 +70,7 @@ final class BeanMethod extends ConfigurationMethod {
return "BeanMethod: " + this.metadata;
}
private class NonOverridableMethodError extends Problem {
NonOverridableMethodError() {

4
spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClass.java

@ -237,8 +237,8 @@ final class ConfigurationClass { @@ -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())));
}

8
spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java

@ -211,8 +211,8 @@ class ConfigurationClassParser { @@ -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 { @@ -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())));
}

12
spring-core-test/src/main/java/org/springframework/core/test/tools/ClassFiles.java

@ -61,6 +61,7 @@ public final class ClassFiles implements Iterable<ClassFile> { @@ -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> { @@ -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

17
spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicFile.java

@ -18,7 +18,6 @@ package org.springframework.core.test.tools; @@ -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 { @@ -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

12
spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicFiles.java

@ -39,7 +39,6 @@ final class DynamicFiles<F extends DynamicFile> implements Iterable<F> { @@ -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> { @@ -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

11
spring-core-test/src/main/java/org/springframework/core/test/tools/ResourceFiles.java

@ -130,15 +130,10 @@ public final class ResourceFiles implements Iterable<ResourceFile> { @@ -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

16
spring-core-test/src/main/java/org/springframework/core/test/tools/SourceFiles.java

@ -17,7 +17,6 @@ @@ -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> { @@ -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

15
spring-core/src/main/java/org/springframework/aot/generate/MethodName.java

@ -91,19 +91,13 @@ final class MethodName { @@ -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 { @@ -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()));

4
spring-core/src/main/java/org/springframework/core/AttributeAccessorSupport.java

@ -105,8 +105,8 @@ public abstract class AttributeAccessorSupport implements AttributeAccessor, Ser @@ -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)));
}

8
spring-core/src/main/java/org/springframework/core/ParameterizedTypeReference.java

@ -14,7 +14,6 @@ @@ -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> { @@ -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> { @@ -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) {

4
spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java

@ -779,8 +779,8 @@ public class TypeDescriptor implements Serializable { @@ -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)));
}

20
spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java vendored

@ -168,30 +168,20 @@ final class ProfilesParser { @@ -168,30 +168,20 @@ 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
public String toString() {
return StringUtils.collectionToDelimitedString(this.expressions, " or ");
}
}
}

8
spring-core/src/main/java/org/springframework/core/env/PropertySource.java vendored

@ -1,5 +1,5 @@ @@ -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> { @@ -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())));
}
/**

4
spring-core/src/main/java/org/springframework/core/io/AbstractResource.java

@ -236,8 +236,8 @@ public abstract class AbstractResource implements Resource { @@ -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())));
}

4
spring-core/src/main/java/org/springframework/core/io/ByteArrayResource.java

@ -129,8 +129,8 @@ public class ByteArrayResource extends AbstractResource { @@ -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)));
}

9
spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java

@ -268,13 +268,10 @@ public class ClassPathResource extends AbstractFileResolvingResource { @@ -268,13 +268,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())));
}
/**

4
spring-core/src/main/java/org/springframework/core/io/DescriptiveResource.java

@ -72,8 +72,8 @@ public class DescriptiveResource extends AbstractResource { @@ -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)));
}

4
spring-core/src/main/java/org/springframework/core/io/FileSystemResource.java

@ -395,8 +395,8 @@ public class FileSystemResource extends AbstractResource implements WritableReso @@ -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)));
}
/**

4
spring-core/src/main/java/org/springframework/core/io/InputStreamResource.java

@ -115,8 +115,8 @@ public class InputStreamResource extends AbstractResource { @@ -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)));
}

4
spring-core/src/main/java/org/springframework/core/io/PathResource.java

@ -298,8 +298,8 @@ public class PathResource extends AbstractResource implements WritableResource { @@ -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)));
}
/**

4
spring-core/src/main/java/org/springframework/core/io/UrlResource.java

@ -343,8 +343,8 @@ public class UrlResource extends AbstractFileResolvingResource { @@ -343,8 +343,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())));
}

5
spring-core/src/main/java/org/springframework/core/io/VfsResource.java

@ -130,9 +130,8 @@ public class VfsResource extends AbstractResource { @@ -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

5
spring-core/src/main/java/org/springframework/core/io/buffer/Netty5DataBuffer.java

@ -337,8 +337,8 @@ public final class Netty5DataBuffer implements CloseableDataBuffer, TouchableDat @@ -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 @@ -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;

5
spring-core/src/main/java/org/springframework/core/io/buffer/NettyDataBuffer.java

@ -363,8 +363,8 @@ public class NettyDataBuffer implements PooledDataBuffer { @@ -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 { @@ -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;

5
spring-core/src/main/java/org/springframework/core/type/StandardClassMetadata.java

@ -120,9 +120,10 @@ public class StandardClassMetadata implements ClassMetadata { @@ -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())));
}

5
spring-core/src/main/java/org/springframework/core/type/StandardMethodMetadata.java

@ -149,9 +149,10 @@ public class StandardMethodMetadata implements MethodMetadata { @@ -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)));
}

4
spring-core/src/main/java/org/springframework/core/type/classreading/SimpleAnnotationMetadata.java

@ -163,8 +163,8 @@ final class SimpleAnnotationMetadata implements AnnotationMetadata { @@ -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

18
spring-core/src/main/java/org/springframework/core/type/classreading/SimpleAnnotationMetadataReadingVisitor.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -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;
}
}
}

5
spring-core/src/main/java/org/springframework/core/type/classreading/SimpleMethodMetadata.java

@ -100,9 +100,10 @@ final class SimpleMethodMetadata implements MethodMetadata { @@ -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

69
spring-core/src/main/java/org/springframework/util/UnmodifiableMultiValueMap.java

@ -66,6 +66,7 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial @@ -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 @@ -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,14 +120,15 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial @@ -119,14 +120,15 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
return this.delegate.toSingleValueMap();
}
@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
@ -134,6 +136,7 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial @@ -134,6 +136,7 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
return this.delegate.toString();
}
// lazy init
@Override
@ -239,20 +242,17 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -728,6 +711,6 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
return this.delegate.getComparator();
}
}
}
}

4
spring-core/src/main/java/org/springframework/util/comparator/BooleanComparator.java

@ -69,8 +69,8 @@ public class BooleanComparator implements Comparator<Boolean>, Serializable { @@ -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

4
spring-messaging/src/main/java/org/springframework/messaging/MessageHeaders.java

@ -333,8 +333,8 @@ public class MessageHeaders implements Map<String, Object>, Serializable { @@ -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

4
spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessageMappingInfo.java

@ -77,8 +77,8 @@ public class SimpMessageMappingInfo implements MessageCondition<SimpMessageMappi @@ -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

4
spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java

@ -477,8 +477,8 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry { @@ -477,8 +477,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

4
spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaders.java

@ -554,8 +554,8 @@ public class StompHeaders implements MultiValueMap<String, String>, Serializable @@ -554,8 +554,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

8
spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java

@ -369,8 +369,8 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati @@ -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 @@ -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

5
spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringFlushSynchronization.java

@ -43,10 +43,9 @@ public class SpringFlushSynchronization implements TransactionSynchronization { @@ -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

21
spring-test/src/main/java/org/springframework/test/context/support/DynamicPropertiesContextCustomizer.java

@ -47,7 +47,6 @@ class DynamicPropertiesContextCustomizer implements ContextCustomizer { @@ -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 { @@ -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 { @@ -91,20 +88,16 @@ class DynamicPropertiesContextCustomizer implements ContextCustomizer {
return this.methods;
}
@Override
public int hashCode() {
return this.methods.hashCode();
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof DynamicPropertiesContextCustomizer that &&
this.methods.equals(that.methods)));
}
@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);
public int hashCode() {
return this.methods.hashCode();
}
}

12
spring-web/src/main/java/org/springframework/http/DefaultHttpStatusCode.java

@ -27,8 +27,7 @@ import org.springframework.lang.Nullable; @@ -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,19 +78,20 @@ final class DefaultHttpStatusCode @@ -79,19 +78,20 @@ final class DefaultHttpStatusCode
return this.value / 100;
}
@Override
public int compareTo(@NonNull HttpStatusCode o) {
return Integer.compare(this.value, o.value());
}
@Override
public int hashCode() {
return this.value;
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof HttpStatusCode that && this.value == that.value()));
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj) || (obj instanceof HttpStatusCode that && this.value == that.value());
public int hashCode() {
return this.value;
}
@Override

25
spring-web/src/main/java/org/springframework/http/HttpHeaders.java

@ -1834,21 +1834,8 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable @@ -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 @@ -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);

4
spring-web/src/main/java/org/springframework/http/HttpMethod.java

@ -170,8 +170,8 @@ public final class HttpMethod implements Comparable<HttpMethod>, Serializable { @@ -170,8 +170,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

8
spring-web/src/main/java/org/springframework/http/server/DefaultPathContainer.java

@ -74,8 +74,8 @@ final class DefaultPathContainer implements PathContainer { @@ -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 { @@ -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

8
spring-web/src/main/java/org/springframework/web/multipart/MultipartFileResource.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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

Loading…
Cancel
Save