Browse Source

Consistent equals/hashCode style (and related polishing)

pull/30915/head
Juergen Hoeller 3 years ago
parent
commit
2f33e77ab4
  1. 9
      spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java
  2. 21
      spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java
  3. 9
      spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJPointcutAdvisor.java
  4. 33
      spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java
  5. 10
      spring-aop/src/main/java/org/springframework/aop/target/EmptyTargetSource.java
  6. 15
      spring-beans/src/main/java/org/springframework/beans/BeanMetadataAttribute.java
  7. 15
      spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java
  8. 12
      spring-beans/src/main/java/org/springframework/beans/GenericTypeAwarePropertyDescriptor.java
  9. 13
      spring-beans/src/main/java/org/springframework/beans/PropertyValue.java
  10. 9
      spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java
  11. 15
      spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinitionHolder.java
  12. 11
      spring-beans/src/main/java/org/springframework/beans/factory/config/BeanExpressionContext.java
  13. 11
      spring-beans/src/main/java/org/springframework/beans/factory/config/RuntimeBeanNameReference.java
  14. 13
      spring-beans/src/main/java/org/springframework/beans/factory/config/RuntimeBeanReference.java
  15. 13
      spring-beans/src/main/java/org/springframework/beans/factory/config/TypedStringValue.java
  16. 11
      spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java
  17. 11
      spring-beans/src/main/java/org/springframework/beans/factory/support/ChildBeanDefinition.java
  18. 9
      spring-beans/src/main/java/org/springframework/beans/factory/support/GenericBeanDefinition.java
  19. 10
      spring-beans/src/main/java/org/springframework/beans/factory/support/LookupOverride.java
  20. 13
      spring-beans/src/main/java/org/springframework/beans/factory/support/MethodOverride.java
  21. 11
      spring-beans/src/main/java/org/springframework/beans/factory/support/MethodOverrides.java
  22. 8
      spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java
  23. 15
      spring-beans/src/main/java/org/springframework/beans/support/MutableSortDefinition.java
  24. 6
      spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/SerializablePerson.java
  25. 11
      spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/TestBean.java
  26. 9
      spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheOperationSourcePointcut.java
  27. 25
      spring-context-support/src/main/java/org/springframework/mail/SimpleMailMessage.java
  28. 11
      spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java
  29. 8
      spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigApplicationContext.java
  30. 11
      spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java
  31. 13
      spring-context/src/main/java/org/springframework/context/expression/AnnotatedElementKey.java
  32. 13
      spring-context/src/main/java/org/springframework/context/expression/CachedExpressionEvaluator.java
  33. 2
      spring-context/src/main/java/org/springframework/context/support/AbstractXmlApplicationContext.java
  34. 15
      spring-context/src/main/java/org/springframework/context/support/DefaultMessageSourceResolvable.java
  35. 9
      spring-context/src/main/java/org/springframework/format/support/FormattingConversionService.java
  36. 10
      spring-context/src/main/java/org/springframework/jmx/access/MBeanClientInterceptor.java
  37. 17
      spring-context/src/main/java/org/springframework/jmx/support/NotificationListenerHolder.java
  38. 15
      spring-context/src/main/java/org/springframework/scheduling/support/CronSequenceGenerator.java
  39. 15
      spring-context/src/main/java/org/springframework/scheduling/support/PeriodicTrigger.java
  40. 13
      spring-context/src/main/java/org/springframework/validation/AbstractBindingResult.java
  41. 24
      spring-core/src/main/java/org/springframework/aot/hint/AbstractTypeReference.java
  42. 13
      spring-core/src/main/java/org/springframework/core/MethodClassKey.java
  43. 17
      spring-core/src/main/java/org/springframework/core/MethodParameter.java
  44. 11
      spring-core/src/main/java/org/springframework/core/ResolvableType.java
  45. 17
      spring-core/src/main/java/org/springframework/core/convert/Property.java
  46. 20
      spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java
  47. 8
      spring-core/src/main/java/org/springframework/core/env/CommandLinePropertySource.java
  48. 13
      spring-core/src/main/java/org/springframework/core/io/buffer/DefaultDataBuffer.java
  49. 13
      spring-core/src/main/java/org/springframework/core/io/support/EncodedResource.java
  50. 22
      spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java
  51. 13
      spring-core/src/main/java/org/springframework/util/MimeType.java
  52. 14
      spring-core/src/main/java/org/springframework/util/comparator/NullSafeComparator.java
  53. 4
      spring-core/src/testFixtures/java/org/springframework/core/testfixture/env/MockPropertySource.java
  54. 15
      spring-expression/src/main/java/org/springframework/expression/TypedValue.java
  55. 11
      spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java
  56. 19
      spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java
  57. 18
      spring-jms/src/main/java/org/springframework/jms/support/QosSettings.java
  58. 11
      spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java
  59. 11
      spring-messaging/src/main/java/org/springframework/messaging/support/GenericMessage.java
  60. 11
      spring-messaging/src/test/java/org/springframework/messaging/simp/user/TestSimpSubscription.java
  61. 4
      spring-test/src/main/java/org/springframework/mock/env/MockEnvironment.java
  62. 2
      spring-test/src/main/java/org/springframework/mock/env/MockPropertySource.java
  63. 25
      spring-test/src/main/java/org/springframework/test/context/ContextConfigurationAttributes.java
  64. 4
      spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java
  65. 13
      spring-test/src/test/java/org/springframework/test/web/Person.java
  66. 11
      spring-tx/src/main/java/org/springframework/transaction/interceptor/MatchAlwaysTransactionAttributeSource.java
  67. 11
      spring-tx/src/main/java/org/springframework/transaction/interceptor/RollbackRuleAttribute.java
  68. 23
      spring-web/src/main/java/org/springframework/http/ContentDisposition.java
  69. 17
      spring-web/src/main/java/org/springframework/http/HttpCookie.java
  70. 22
      spring-web/src/main/java/org/springframework/http/HttpRange.java
  71. 19
      spring-web/src/main/java/org/springframework/http/ProblemDetail.java
  72. 15
      spring-web/src/main/java/org/springframework/http/ResponseCookie.java
  73. 4
      spring-web/src/main/java/org/springframework/http/client/observation/ClientRequestObservationContext.java
  74. 2
      spring-web/src/main/java/org/springframework/http/client/reactive/ReactorNetty2ClientHttpResponse.java
  75. 9
      spring-web/src/main/java/org/springframework/web/context/support/ServletContextResource.java
  76. 4
      spring-web/src/main/java/org/springframework/web/filter/DelegatingFilterProxy.java
  77. 11
      spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java
  78. 4
      spring-web/src/main/java/org/springframework/web/server/session/HeaderWebSessionIdResolver.java
  79. 23
      spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java
  80. 15
      spring-web/src/main/java/org/springframework/web/util/OpaqueUriComponents.java
  81. 10
      spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java
  82. 13
      spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctions.java
  83. 9
      spring-webflux/src/main/java/org/springframework/web/reactive/resource/CssLinkResourceTransformer.java
  84. 4
      spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/AbstractMediaTypeExpression.java
  85. 21
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.java
  86. 11
      spring-webflux/src/main/java/org/springframework/web/reactive/socket/CloseStatus.java
  87. 13
      spring-webflux/src/main/java/org/springframework/web/reactive/socket/WebSocketMessage.java
  88. 15
      spring-webmvc/src/main/java/org/springframework/web/servlet/FlashMap.java
  89. 4
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractMediaTypeExpression.java
  90. 21
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java
  91. 11
      spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CssLinkResourceTransformer.java
  92. 16
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateView.java
  93. 10
      spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ItemPet.java
  94. 11
      spring-websocket/src/main/java/org/springframework/web/socket/AbstractWebSocketMessage.java
  95. 9
      spring-websocket/src/main/java/org/springframework/web/socket/CloseStatus.java
  96. 9
      spring-websocket/src/main/java/org/springframework/web/socket/WebSocketHttpHeaders.java
  97. 19
      spring-websocket/src/main/java/org/springframework/web/socket/messaging/DefaultSimpUserRegistry.java
  98. 9
      spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/SockJsFrame.java

9
spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java

@ -714,13 +714,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence @@ -714,13 +714,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AdviceExcludingMethodMatcher otherMm)) {
return false;
}
return this.adviceMethod.equals(otherMm.adviceMethod);
return (this == other || (other instanceof AdviceExcludingMethodMatcher that &&
this.adviceMethod.equals(that.adviceMethod)));
}
@Override

21
spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java

@ -243,8 +243,8 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut @@ -243,8 +243,8 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
/**
* If a pointcut expression has been specified in XML, the user cannot
* write {@code and} as "&&" (though && will work).
* We also allow {@code and} between two pointcut sub-expressions.
* write "and" as "&&" (though {@code &&} will work).
* <p>We also allow "and" between two pointcut sub-expressions.
* <p>This method converts back to {@code &&} for the AspectJ pointcut parser.
*/
private String replaceBooleanOperators(String pcExpr) {
@ -516,21 +516,16 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut @@ -516,21 +516,16 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AspectJExpressionPointcut otherPc)) {
return false;
}
return ObjectUtils.nullSafeEquals(this.getExpression(), otherPc.getExpression()) &&
ObjectUtils.nullSafeEquals(this.pointcutDeclarationScope, otherPc.pointcutDeclarationScope) &&
ObjectUtils.nullSafeEquals(this.pointcutParameterNames, otherPc.pointcutParameterNames) &&
ObjectUtils.nullSafeEquals(this.pointcutParameterTypes, otherPc.pointcutParameterTypes);
return (this == other || (other instanceof AspectJExpressionPointcut that &&
ObjectUtils.nullSafeEquals(getExpression(), that.getExpression()) &&
ObjectUtils.nullSafeEquals(this.pointcutDeclarationScope, that.pointcutDeclarationScope) &&
ObjectUtils.nullSafeEquals(this.pointcutParameterNames, that.pointcutParameterNames) &&
ObjectUtils.nullSafeEquals(this.pointcutParameterTypes, that.pointcutParameterTypes)));
}
@Override
public int hashCode() {
int hashCode = ObjectUtils.nullSafeHashCode(this.getExpression());
int hashCode = ObjectUtils.nullSafeHashCode(getExpression());
hashCode = 31 * hashCode + ObjectUtils.nullSafeHashCode(this.pointcutDeclarationScope);
hashCode = 31 * hashCode + ObjectUtils.nullSafeHashCode(this.pointcutParameterNames);
hashCode = 31 * hashCode + ObjectUtils.nullSafeHashCode(this.pointcutParameterTypes);

9
spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJPointcutAdvisor.java

@ -89,13 +89,8 @@ public class AspectJPointcutAdvisor implements PointcutAdvisor, Ordered { @@ -89,13 +89,8 @@ public class AspectJPointcutAdvisor implements PointcutAdvisor, Ordered {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AspectJPointcutAdvisor otherAdvisor)) {
return false;
}
return this.advice.equals(otherAdvisor.advice);
return (this == other || (other instanceof AspectJPointcutAdvisor that &&
this.advice.equals(that.advice)));
}
@Override

33
spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java

@ -597,15 +597,10 @@ class CglibAopProxy implements AopProxy, Serializable { @@ -597,15 +597,10 @@ class CglibAopProxy implements AopProxy, Serializable {
}
if (other instanceof Factory factory) {
Callback callback = factory.getCallback(INVOKE_EQUALS);
if (!(callback instanceof EqualsInterceptor equalsInterceptor)) {
return false;
}
AdvisedSupport otherAdvised = equalsInterceptor.advised;
return AopProxyUtils.equalsInProxy(this.advised, otherAdvised);
}
else {
return false;
return (callback instanceof EqualsInterceptor that &&
AopProxyUtils.equalsInProxy(this.advised, that.advised));
}
return false;
}
}
@ -920,20 +915,14 @@ class CglibAopProxy implements AopProxy, Serializable { @@ -920,20 +915,14 @@ class CglibAopProxy implements AopProxy, Serializable {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ProxyCallbackFilter otherCallbackFilter)) {
return false;
}
AdvisedSupport otherAdvised = otherCallbackFilter.advised;
return (this.advised.getAdvisorKey().equals(otherAdvised.getAdvisorKey()) &&
AopProxyUtils.equalsProxiedInterfaces(this.advised, otherAdvised) &&
ObjectUtils.nullSafeEquals(this.advised.getTargetClass(), otherAdvised.getTargetClass()) &&
this.advised.getTargetSource().isStatic() == otherAdvised.getTargetSource().isStatic() &&
this.advised.isFrozen() == otherAdvised.isFrozen() &&
this.advised.isExposeProxy() == otherAdvised.isExposeProxy() &&
this.advised.isOpaque() == otherAdvised.isOpaque());
return (this == other || (other instanceof ProxyCallbackFilter that &&
this.advised.getAdvisorKey().equals(that.advised.getAdvisorKey()) &&
AopProxyUtils.equalsProxiedInterfaces(this.advised, that.advised) &&
ObjectUtils.nullSafeEquals(this.advised.getTargetClass(), that.advised.getTargetClass()) &&
this.advised.getTargetSource().isStatic() == that.advised.getTargetSource().isStatic() &&
this.advised.isFrozen() == that.advised.isFrozen() &&
this.advised.isExposeProxy() == that.advised.isExposeProxy() &&
this.advised.isOpaque() == that.advised.isOpaque()));
}
@Override

10
spring-aop/src/main/java/org/springframework/aop/target/EmptyTargetSource.java

@ -133,13 +133,9 @@ public final class EmptyTargetSource implements TargetSource, Serializable { @@ -133,13 +133,9 @@ public final class EmptyTargetSource implements TargetSource, Serializable {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof EmptyTargetSource otherTs)) {
return false;
}
return (ObjectUtils.nullSafeEquals(this.targetClass, otherTs.targetClass) && this.isStatic == otherTs.isStatic);
return (this == other || (other instanceof EmptyTargetSource that &&
ObjectUtils.nullSafeEquals(this.targetClass, that.targetClass) &&
this.isStatic == that.isStatic));
}
@Override

15
spring-beans/src/main/java/org/springframework/beans/BeanMetadataAttribute.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.
@ -82,15 +82,10 @@ public class BeanMetadataAttribute implements BeanMetadataElement { @@ -82,15 +82,10 @@ public class BeanMetadataAttribute implements BeanMetadataElement {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof BeanMetadataAttribute otherMa)) {
return false;
}
return (this.name.equals(otherMa.name) &&
ObjectUtils.nullSafeEquals(this.value, otherMa.value) &&
ObjectUtils.nullSafeEquals(this.source, otherMa.source));
return (this == other ||(other instanceof BeanMetadataAttribute that &&
this.name.equals(that.name) &&
ObjectUtils.nullSafeEquals(this.value, that.value) &&
ObjectUtils.nullSafeEquals(this.source, that.source)));
}
@Override

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

@ -491,16 +491,11 @@ class ExtendedBeanInfo implements BeanInfo { @@ -491,16 +491,11 @@ class ExtendedBeanInfo implements BeanInfo {
*/
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof IndexedPropertyDescriptor otherPd)) {
return false;
}
return (ObjectUtils.nullSafeEquals(getIndexedReadMethod(), otherPd.getIndexedReadMethod()) &&
ObjectUtils.nullSafeEquals(getIndexedWriteMethod(), otherPd.getIndexedWriteMethod()) &&
ObjectUtils.nullSafeEquals(getIndexedPropertyType(), otherPd.getIndexedPropertyType()) &&
PropertyDescriptorUtils.equals(this, otherPd));
return (this == other || (other instanceof IndexedPropertyDescriptor that &&
ObjectUtils.nullSafeEquals(getIndexedReadMethod(), that.getIndexedReadMethod()) &&
ObjectUtils.nullSafeEquals(getIndexedWriteMethod(), that.getIndexedWriteMethod()) &&
ObjectUtils.nullSafeEquals(getIndexedPropertyType(), that.getIndexedPropertyType()) &&
PropertyDescriptorUtils.equals(this, that)));
}
@Override

12
spring-beans/src/main/java/org/springframework/beans/GenericTypeAwarePropertyDescriptor.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.
@ -165,13 +165,9 @@ final class GenericTypeAwarePropertyDescriptor extends PropertyDescriptor { @@ -165,13 +165,9 @@ final class GenericTypeAwarePropertyDescriptor extends PropertyDescriptor {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof GenericTypeAwarePropertyDescriptor otherPd)) {
return false;
}
return (getBeanClass().equals(otherPd.getBeanClass()) && PropertyDescriptorUtils.equals(this, otherPd));
return (this == other || (other instanceof GenericTypeAwarePropertyDescriptor that &&
getBeanClass().equals(that.getBeanClass()) &&
PropertyDescriptorUtils.equals(this, that)));
}
@Override

13
spring-beans/src/main/java/org/springframework/beans/PropertyValue.java

@ -189,15 +189,10 @@ public class PropertyValue extends BeanMetadataAttributeAccessor implements Seri @@ -189,15 +189,10 @@ public class PropertyValue extends BeanMetadataAttributeAccessor implements Seri
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof PropertyValue otherPv)) {
return false;
}
return (this.name.equals(otherPv.name) &&
ObjectUtils.nullSafeEquals(this.value, otherPv.value) &&
ObjectUtils.nullSafeEquals(getSource(), otherPv.getSource()));
return (this == other || (other instanceof PropertyValue that &&
this.name.equals(that.name) &&
ObjectUtils.nullSafeEquals(this.value, that.value) &&
ObjectUtils.nullSafeEquals(getSource(), that.getSource())));
}
@Override

9
spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java

@ -340,13 +340,8 @@ public class InjectionMetadata { @@ -340,13 +340,8 @@ public class InjectionMetadata {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof InjectedElement otherElement)) {
return false;
}
return this.member.equals(otherElement.member);
return (this == other || (other instanceof InjectedElement that &&
this.member.equals(that.member)));
}
@Override

15
spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinitionHolder.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.
@ -165,15 +165,10 @@ public class BeanDefinitionHolder implements BeanMetadataElement { @@ -165,15 +165,10 @@ public class BeanDefinitionHolder implements BeanMetadataElement {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof BeanDefinitionHolder otherHolder)) {
return false;
}
return this.beanDefinition.equals(otherHolder.beanDefinition) &&
this.beanName.equals(otherHolder.beanName) &&
ObjectUtils.nullSafeEquals(this.aliases, otherHolder.aliases);
return (this == other || (other instanceof BeanDefinitionHolder that &&
this.beanDefinition.equals(that.beanDefinition) &&
this.beanName.equals(that.beanName) &&
ObjectUtils.nullSafeEquals(this.aliases, that.aliases)));
}
@Override

11
spring-beans/src/main/java/org/springframework/beans/factory/config/BeanExpressionContext.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.
@ -70,13 +70,8 @@ public class BeanExpressionContext { @@ -70,13 +70,8 @@ public class BeanExpressionContext {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof BeanExpressionContext otherContext)) {
return false;
}
return (this.beanFactory == otherContext.beanFactory && this.scope == otherContext.scope);
return (this == other || (other instanceof BeanExpressionContext that &&
this.beanFactory == that.beanFactory && this.scope == that.scope));
}
@Override

11
spring-beans/src/main/java/org/springframework/beans/factory/config/RuntimeBeanNameReference.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.
@ -68,13 +68,8 @@ public class RuntimeBeanNameReference implements BeanReference { @@ -68,13 +68,8 @@ public class RuntimeBeanNameReference implements BeanReference {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof RuntimeBeanNameReference that)) {
return false;
}
return this.beanName.equals(that.beanName);
return (this == other || (other instanceof RuntimeBeanNameReference that &&
this.beanName.equals(that.beanName)));
}
@Override

13
spring-beans/src/main/java/org/springframework/beans/factory/config/RuntimeBeanReference.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.
@ -132,14 +132,9 @@ public class RuntimeBeanReference implements BeanReference { @@ -132,14 +132,9 @@ public class RuntimeBeanReference implements BeanReference {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof RuntimeBeanReference that)) {
return false;
}
return (this.beanName.equals(that.beanName) && this.beanType == that.beanType &&
this.toParent == that.toParent);
return (this == other || (other instanceof RuntimeBeanReference that &&
this.beanName.equals(that.beanName) && this.beanType == that.beanType &&
this.toParent == that.toParent));
}
@Override

13
spring-beans/src/main/java/org/springframework/beans/factory/config/TypedStringValue.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.
@ -216,14 +216,9 @@ public class TypedStringValue implements BeanMetadataElement { @@ -216,14 +216,9 @@ public class TypedStringValue implements BeanMetadataElement {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof TypedStringValue otherValue)) {
return false;
}
return (ObjectUtils.nullSafeEquals(this.value, otherValue.value) &&
ObjectUtils.nullSafeEquals(this.targetType, otherValue.targetType));
return (this == other || (other instanceof TypedStringValue that &&
ObjectUtils.nullSafeEquals(this.value, that.value) &&
ObjectUtils.nullSafeEquals(this.targetType, that.targetType)));
}
@Override

11
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java

@ -1211,13 +1211,8 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess @@ -1211,13 +1211,8 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AbstractBeanDefinition that)) {
return false;
}
return (ObjectUtils.nullSafeEquals(getBeanClassName(), that.getBeanClassName()) &&
return (this == other || (other instanceof AbstractBeanDefinition that &&
ObjectUtils.nullSafeEquals(getBeanClassName(), that.getBeanClassName()) &&
ObjectUtils.nullSafeEquals(this.scope, that.scope) &&
this.abstractFlag == that.abstractFlag &&
this.lazyInit == that.lazyInit &&
@ -1240,7 +1235,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess @@ -1240,7 +1235,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
this.enforceDestroyMethod == that.enforceDestroyMethod &&
this.synthetic == that.synthetic &&
this.role == that.role &&
super.equals(other));
super.equals(other)));
}
private boolean equalsConstructorArgumentValues(AbstractBeanDefinition other) {

11
spring-beans/src/main/java/org/springframework/beans/factory/support/ChildBeanDefinition.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.
@ -157,13 +157,8 @@ public class ChildBeanDefinition extends AbstractBeanDefinition { @@ -157,13 +157,8 @@ public class ChildBeanDefinition extends AbstractBeanDefinition {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ChildBeanDefinition that)) {
return false;
}
return (ObjectUtils.nullSafeEquals(this.parentName, that.parentName) && super.equals(other));
return (this == other || (other instanceof ChildBeanDefinition that &&
ObjectUtils.nullSafeEquals(this.parentName, that.parentName) && super.equals(other)));
}
@Override

9
spring-beans/src/main/java/org/springframework/beans/factory/support/GenericBeanDefinition.java

@ -87,13 +87,8 @@ public class GenericBeanDefinition extends AbstractBeanDefinition { @@ -87,13 +87,8 @@ public class GenericBeanDefinition extends AbstractBeanDefinition {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof GenericBeanDefinition that)) {
return false;
}
return (ObjectUtils.nullSafeEquals(this.parentName, that.parentName) && super.equals(other));
return (this == other || (other instanceof GenericBeanDefinition that &&
ObjectUtils.nullSafeEquals(this.parentName, that.parentName) && super.equals(other)));
}
@Override

10
spring-beans/src/main/java/org/springframework/beans/factory/support/LookupOverride.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.
@ -102,16 +102,14 @@ public class LookupOverride extends MethodOverride { @@ -102,16 +102,14 @@ public class LookupOverride extends MethodOverride {
@Override
public boolean equals(@Nullable Object other) {
if (!(other instanceof LookupOverride that) || !super.equals(other)) {
return false;
}
return (ObjectUtils.nullSafeEquals(this.method, that.method) &&
return (other instanceof LookupOverride that && super.equals(other) &&
ObjectUtils.nullSafeEquals(this.method, that.method) &&
ObjectUtils.nullSafeEquals(this.beanName, that.beanName));
}
@Override
public int hashCode() {
return (29 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.beanName));
return super.hashCode() * 29 + ObjectUtils.nullSafeHashCode(this.beanName);
}
@Override

13
spring-beans/src/main/java/org/springframework/beans/factory/support/MethodOverride.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.
@ -106,14 +106,9 @@ public abstract class MethodOverride implements BeanMetadataElement { @@ -106,14 +106,9 @@ public abstract class MethodOverride implements BeanMetadataElement {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof MethodOverride that)) {
return false;
}
return (ObjectUtils.nullSafeEquals(this.methodName, that.methodName) &&
ObjectUtils.nullSafeEquals(this.source, that.source));
return (this == other || (other instanceof MethodOverride that &&
ObjectUtils.nullSafeEquals(this.methodName, that.methodName) &&
ObjectUtils.nullSafeEquals(this.source, that.source)));
}
@Override

11
spring-beans/src/main/java/org/springframework/beans/factory/support/MethodOverrides.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.
@ -104,13 +104,8 @@ public class MethodOverrides { @@ -104,13 +104,8 @@ public class MethodOverrides {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof MethodOverrides that)) {
return false;
}
return this.overrides.equals(that.overrides);
return (this == other || (other instanceof MethodOverrides that &&
this.overrides.equals(that.overrides)));
}
@Override

8
spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.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.
@ -97,10 +97,8 @@ public class ReplaceOverride extends MethodOverride { @@ -97,10 +97,8 @@ public class ReplaceOverride extends MethodOverride {
@Override
public boolean equals(@Nullable Object other) {
if (!(other instanceof ReplaceOverride that) || !super.equals(other)) {
return false;
}
return (ObjectUtils.nullSafeEquals(this.methodReplacerBeanName, that.methodReplacerBeanName) &&
return (other instanceof ReplaceOverride that && super.equals(other) &&
ObjectUtils.nullSafeEquals(this.methodReplacerBeanName, that.methodReplacerBeanName) &&
ObjectUtils.nullSafeEquals(this.typeIdentifiers, that.typeIdentifiers));
}

15
spring-beans/src/main/java/org/springframework/beans/support/MutableSortDefinition.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.
@ -156,15 +156,10 @@ public class MutableSortDefinition implements SortDefinition, Serializable { @@ -156,15 +156,10 @@ public class MutableSortDefinition implements SortDefinition, Serializable {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof SortDefinition otherSd)) {
return false;
}
return (getProperty().equals(otherSd.getProperty()) &&
isAscending() == otherSd.isAscending() &&
isIgnoreCase() == otherSd.isIgnoreCase());
return (this == other || (other instanceof SortDefinition that &&
getProperty().equals(that.getProperty()) &&
isAscending() == that.isAscending() &&
isIgnoreCase() == that.isIgnoreCase()));
}
@Override

6
spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/SerializablePerson.java

@ -65,10 +65,8 @@ public class SerializablePerson implements Person, Serializable { @@ -65,10 +65,8 @@ public class SerializablePerson implements Person, Serializable {
@Override
public boolean equals(@Nullable Object other) {
if (!(other instanceof SerializablePerson p)) {
return false;
}
return p.age == age && ObjectUtils.nullSafeEquals(name, p.name);
return (this == other || (other instanceof SerializablePerson that &&
ObjectUtils.nullSafeEquals(this.name, that.name) && this.age == that.age));
}
@Override

11
spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/TestBean.java

@ -466,18 +466,13 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt @@ -466,18 +466,13 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof TestBean tb2)) {
return false;
}
return (ObjectUtils.nullSafeEquals(this.name, tb2.name) && this.age == tb2.age);
return (this == other || (other instanceof TestBean that &&
ObjectUtils.nullSafeEquals(this.name, that.name) && this.age == that.age));
}
@Override
public int hashCode() {
return this.age;
return TestBean.class.hashCode();
}
@Override

9
spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheOperationSourcePointcut.java vendored

@ -51,13 +51,8 @@ public abstract class JCacheOperationSourcePointcut extends StaticMethodMatcherP @@ -51,13 +51,8 @@ public abstract class JCacheOperationSourcePointcut extends StaticMethodMatcherP
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof JCacheOperationSourcePointcut otherPc)) {
return false;
}
return ObjectUtils.nullSafeEquals(getCacheOperationSource(), otherPc.getCacheOperationSource());
return (this == other || (other instanceof JCacheOperationSourcePointcut that &&
ObjectUtils.nullSafeEquals(getCacheOperationSource(), that.getCacheOperationSource())));
}
@Override

25
spring-context-support/src/main/java/org/springframework/mail/SimpleMailMessage.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.
@ -223,20 +223,15 @@ public class SimpleMailMessage implements MailMessage, Serializable { @@ -223,20 +223,15 @@ public class SimpleMailMessage implements MailMessage, Serializable {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof SimpleMailMessage otherMessage)) {
return false;
}
return (ObjectUtils.nullSafeEquals(this.from, otherMessage.from) &&
ObjectUtils.nullSafeEquals(this.replyTo, otherMessage.replyTo) &&
ObjectUtils.nullSafeEquals(this.to, otherMessage.to) &&
ObjectUtils.nullSafeEquals(this.cc, otherMessage.cc) &&
ObjectUtils.nullSafeEquals(this.bcc, otherMessage.bcc) &&
ObjectUtils.nullSafeEquals(this.sentDate, otherMessage.sentDate) &&
ObjectUtils.nullSafeEquals(this.subject, otherMessage.subject) &&
ObjectUtils.nullSafeEquals(this.text, otherMessage.text));
return (this == other || (other instanceof SimpleMailMessage that &&
ObjectUtils.nullSafeEquals(this.from, that.from) &&
ObjectUtils.nullSafeEquals(this.replyTo, that.replyTo) &&
ObjectUtils.nullSafeEquals(this.to, that.to) &&
ObjectUtils.nullSafeEquals(this.cc, that.cc) &&
ObjectUtils.nullSafeEquals(this.bcc, that.bcc) &&
ObjectUtils.nullSafeEquals(this.sentDate, that.sentDate) &&
ObjectUtils.nullSafeEquals(this.subject, that.subject) &&
ObjectUtils.nullSafeEquals(this.text, that.text)));
}
@Override

11
spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java vendored

@ -853,14 +853,9 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker @@ -853,14 +853,9 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof CacheOperationCacheKey otherKey)) {
return false;
}
return (this.cacheOperation.equals(otherKey.cacheOperation) &&
this.methodCacheKey.equals(otherKey.methodCacheKey));
return (this == other || (other instanceof CacheOperationCacheKey that &&
this.cacheOperation.equals(that.cacheOperation) &&
this.methodCacheKey.equals(that.methodCacheKey)));
}
@Override

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 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.
@ -65,7 +65,7 @@ public class AnnotationConfigApplicationContext extends GenericApplicationContex @@ -65,7 +65,7 @@ public class AnnotationConfigApplicationContext extends GenericApplicationContex
* through {@link #register} calls and then manually {@linkplain #refresh refreshed}.
*/
public AnnotationConfigApplicationContext() {
StartupStep createAnnotatedBeanDefReader = this.getApplicationStartup().start("spring.context.annotated-bean-reader.create");
StartupStep createAnnotatedBeanDefReader = getApplicationStartup().start("spring.context.annotated-bean-reader.create");
this.reader = new AnnotatedBeanDefinitionReader(this);
createAnnotatedBeanDefReader.end();
this.scanner = new ClassPathBeanDefinitionScanner(this);
@ -163,7 +163,7 @@ public class AnnotationConfigApplicationContext extends GenericApplicationContex @@ -163,7 +163,7 @@ public class AnnotationConfigApplicationContext extends GenericApplicationContex
@Override
public void register(Class<?>... componentClasses) {
Assert.notEmpty(componentClasses, "At least one component class must be specified");
StartupStep registerComponentClass = this.getApplicationStartup().start("spring.context.component-classes.register")
StartupStep registerComponentClass = getApplicationStartup().start("spring.context.component-classes.register")
.tag("classes", () -> Arrays.toString(componentClasses));
this.reader.register(componentClasses);
registerComponentClass.end();
@ -180,7 +180,7 @@ public class AnnotationConfigApplicationContext extends GenericApplicationContex @@ -180,7 +180,7 @@ public class AnnotationConfigApplicationContext extends GenericApplicationContex
@Override
public void scan(String... basePackages) {
Assert.notEmpty(basePackages, "At least one base package must be specified");
StartupStep scanPackages = this.getApplicationStartup().start("spring.context.base-packages.scan")
StartupStep scanPackages = getApplicationStartup().start("spring.context.base-packages.scan")
.tag("packages", () -> Arrays.toString(basePackages));
this.scanner.scan(basePackages);
scanPackages.end();

11
spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java

@ -397,14 +397,9 @@ public abstract class AbstractApplicationEventMulticaster @@ -397,14 +397,9 @@ public abstract class AbstractApplicationEventMulticaster
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ListenerCacheKey otherKey)) {
return false;
}
return (this.eventType.equals(otherKey.eventType) &&
ObjectUtils.nullSafeEquals(this.sourceType, otherKey.sourceType));
return (this == other || (other instanceof ListenerCacheKey that &&
this.eventType.equals(that.eventType) &&
ObjectUtils.nullSafeEquals(this.sourceType, that.sourceType)));
}
@Override

13
spring-context/src/main/java/org/springframework/context/expression/AnnotatedElementKey.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.
@ -52,14 +52,9 @@ public final class AnnotatedElementKey implements Comparable<AnnotatedElementKey @@ -52,14 +52,9 @@ public final class AnnotatedElementKey implements Comparable<AnnotatedElementKey
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AnnotatedElementKey otherKey)) {
return false;
}
return (this.element.equals(otherKey.element) &&
ObjectUtils.nullSafeEquals(this.targetClass, otherKey.targetClass));
return (this == other || (other instanceof AnnotatedElementKey that &&
this.element.equals(that.element) &&
ObjectUtils.nullSafeEquals(this.targetClass, that.targetClass)));
}
@Override

13
spring-context/src/main/java/org/springframework/context/expression/CachedExpressionEvaluator.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.
@ -124,14 +124,9 @@ public abstract class CachedExpressionEvaluator { @@ -124,14 +124,9 @@ public abstract class CachedExpressionEvaluator {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ExpressionKey otherKey)) {
return false;
}
return (this.element.equals(otherKey.element) &&
ObjectUtils.nullSafeEquals(this.expression, otherKey.expression));
return (this == other || (other instanceof ExpressionKey that &&
this.element.equals(that.element) &&
ObjectUtils.nullSafeEquals(this.expression, that.expression)));
}
@Override

2
spring-context/src/main/java/org/springframework/context/support/AbstractXmlApplicationContext.java

@ -84,7 +84,7 @@ public abstract class AbstractXmlApplicationContext extends AbstractRefreshableC @@ -84,7 +84,7 @@ public abstract class AbstractXmlApplicationContext extends AbstractRefreshableC
// Configure the bean definition reader with this context's
// resource loading environment.
beanDefinitionReader.setEnvironment(this.getEnvironment());
beanDefinitionReader.setEnvironment(getEnvironment());
beanDefinitionReader.setResourceLoader(this);
beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this));

15
spring-context/src/main/java/org/springframework/context/support/DefaultMessageSourceResolvable.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.
@ -171,15 +171,10 @@ public class DefaultMessageSourceResolvable implements MessageSourceResolvable, @@ -171,15 +171,10 @@ public class DefaultMessageSourceResolvable implements MessageSourceResolvable,
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof MessageSourceResolvable otherResolvable)) {
return false;
}
return (ObjectUtils.nullSafeEquals(getCodes(), otherResolvable.getCodes()) &&
ObjectUtils.nullSafeEquals(getArguments(), otherResolvable.getArguments()) &&
ObjectUtils.nullSafeEquals(getDefaultMessage(), otherResolvable.getDefaultMessage()));
return (this == other || (other instanceof MessageSourceResolvable that &&
ObjectUtils.nullSafeEquals(getCodes(), that.getCodes()) &&
ObjectUtils.nullSafeEquals(getArguments(), that.getArguments()) &&
ObjectUtils.nullSafeEquals(getDefaultMessage(), that.getDefaultMessage())));
}
@Override

9
spring-context/src/main/java/org/springframework/format/support/FormattingConversionService.java

@ -367,13 +367,8 @@ public class FormattingConversionService extends GenericConversionService @@ -367,13 +367,8 @@ public class FormattingConversionService extends GenericConversionService
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AnnotationConverterKey otherKey)) {
return false;
}
return (this.fieldType == otherKey.fieldType && this.annotation.equals(otherKey.annotation));
return (this == other || (other instanceof AnnotationConverterKey that &&
this.fieldType == that.fieldType && this.annotation.equals(that.annotation)));
}
@Override

10
spring-context/src/main/java/org/springframework/jmx/access/MBeanClientInterceptor.java

@ -655,13 +655,9 @@ public class MBeanClientInterceptor @@ -655,13 +655,9 @@ public class MBeanClientInterceptor
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof MethodCacheKey otherKey)) {
return false;
}
return (this.name.equals(otherKey.name) && Arrays.equals(this.parameterTypes, otherKey.parameterTypes));
return (this == other || (other instanceof MethodCacheKey that &&
this.name.equals(that.name) &&
Arrays.equals(this.parameterTypes, that.parameterTypes)));
}
@Override

17
spring-context/src/main/java/org/springframework/jmx/support/NotificationListenerHolder.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.
@ -158,16 +158,11 @@ public class NotificationListenerHolder { @@ -158,16 +158,11 @@ public class NotificationListenerHolder {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof NotificationListenerHolder otherNlh)) {
return false;
}
return (ObjectUtils.nullSafeEquals(this.notificationListener, otherNlh.notificationListener) &&
ObjectUtils.nullSafeEquals(this.notificationFilter, otherNlh.notificationFilter) &&
ObjectUtils.nullSafeEquals(this.handback, otherNlh.handback) &&
ObjectUtils.nullSafeEquals(this.mappedObjectNames, otherNlh.mappedObjectNames));
return (this == other || (other instanceof NotificationListenerHolder that &&
ObjectUtils.nullSafeEquals(this.notificationListener, that.notificationListener) &&
ObjectUtils.nullSafeEquals(this.notificationFilter, that.notificationFilter) &&
ObjectUtils.nullSafeEquals(this.handback, that.handback) &&
ObjectUtils.nullSafeEquals(this.mappedObjectNames, that.mappedObjectNames)));
}
@Override

15
spring-context/src/main/java/org/springframework/scheduling/support/CronSequenceGenerator.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.
@ -435,15 +435,10 @@ public class CronSequenceGenerator { @@ -435,15 +435,10 @@ public class CronSequenceGenerator {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof CronSequenceGenerator otherCron)) {
return false;
}
return (this.months.equals(otherCron.months) && this.daysOfMonth.equals(otherCron.daysOfMonth) &&
this.daysOfWeek.equals(otherCron.daysOfWeek) && this.hours.equals(otherCron.hours) &&
this.minutes.equals(otherCron.minutes) && this.seconds.equals(otherCron.seconds));
return (this == other || (other instanceof CronSequenceGenerator that &&
this.months.equals(that.months) && this.daysOfMonth.equals(that.daysOfMonth) &&
this.daysOfWeek.equals(that.daysOfWeek) && this.hours.equals(that.hours) &&
this.minutes.equals(that.minutes) && this.seconds.equals(that.seconds)));
}
@Override

15
spring-context/src/main/java/org/springframework/scheduling/support/PeriodicTrigger.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.
@ -247,15 +247,10 @@ public class PeriodicTrigger implements Trigger { @@ -247,15 +247,10 @@ public class PeriodicTrigger implements Trigger {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof PeriodicTrigger otherTrigger)) {
return false;
}
return (this.fixedRate == otherTrigger.fixedRate &&
this.period.equals(otherTrigger.period) &&
Objects.equals(this.initialDelay, otherTrigger.initialDelay));
return (this == other || (other instanceof PeriodicTrigger that &&
this.fixedRate == that.fixedRate &&
this.period.equals(that.period) &&
Objects.equals(this.initialDelay, that.initialDelay)));
}
@Override

13
spring-context/src/main/java/org/springframework/validation/AbstractBindingResult.java

@ -358,15 +358,10 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi @@ -358,15 +358,10 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof BindingResult otherResult)) {
return false;
}
return (getObjectName().equals(otherResult.getObjectName()) &&
ObjectUtils.nullSafeEquals(getTarget(), otherResult.getTarget()) &&
getAllErrors().equals(otherResult.getAllErrors()));
return (this == other || (other instanceof BindingResult that &&
getObjectName().equals(that.getObjectName()) &&
ObjectUtils.nullSafeEquals(getTarget(), that.getTarget()) &&
getAllErrors().equals(that.getAllErrors())));
}
@Override

24
spring-core/src/main/java/org/springframework/aot/hint/AbstractTypeReference.java

@ -37,12 +37,14 @@ public abstract class AbstractTypeReference implements TypeReference { @@ -37,12 +37,14 @@ public abstract class AbstractTypeReference implements TypeReference {
@Nullable
private final TypeReference enclosingType;
protected AbstractTypeReference(String packageName, String simpleName, @Nullable TypeReference enclosingType) {
this.packageName = packageName;
this.simpleName = simpleName;
this.enclosingType = enclosingType;
}
@Override
public String getName() {
TypeReference enclosingType = getEnclosingType();
@ -67,30 +69,26 @@ public abstract class AbstractTypeReference implements TypeReference { @@ -67,30 +69,26 @@ public abstract class AbstractTypeReference implements TypeReference {
return this.enclosingType;
}
protected abstract boolean isPrimitive();
protected String addPackageIfNecessary(String part) {
if (this.packageName.isEmpty() ||
this.packageName.equals("java.lang") && isPrimitive()) {
(this.packageName.equals("java.lang") && isPrimitive())) {
return part;
}
return this.packageName + '.' + part;
}
protected abstract boolean isPrimitive();
@Override
public int hashCode() {
return Objects.hash(getCanonicalName());
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof TypeReference that &&
getCanonicalName().equals(that.getCanonicalName())));
}
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof TypeReference otherReference)) {
return false;
}
return getCanonicalName().equals(otherReference.getCanonicalName());
public int hashCode() {
return Objects.hash(getCanonicalName());
}
@Override

13
spring-core/src/main/java/org/springframework/core/MethodClassKey.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.
@ -51,14 +51,9 @@ public final class MethodClassKey implements Comparable<MethodClassKey> { @@ -51,14 +51,9 @@ public final class MethodClassKey implements Comparable<MethodClassKey> {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof MethodClassKey otherKey)) {
return false;
}
return (this.method.equals(otherKey.method) &&
ObjectUtils.nullSafeEquals(this.targetClass, otherKey.targetClass));
return (this == other || (other instanceof MethodClassKey that &&
this.method.equals(that.method) &&
ObjectUtils.nullSafeEquals(this.targetClass, that.targetClass)));
}
@Override

17
spring-core/src/main/java/org/springframework/core/MethodParameter.java

@ -750,17 +750,12 @@ public class MethodParameter { @@ -750,17 +750,12 @@ public class MethodParameter {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof MethodParameter otherParam)) {
return false;
}
return (getContainingClass() == otherParam.getContainingClass() &&
ObjectUtils.nullSafeEquals(this.typeIndexesPerLevel, otherParam.typeIndexesPerLevel) &&
this.nestingLevel == otherParam.nestingLevel &&
this.parameterIndex == otherParam.parameterIndex &&
this.executable.equals(otherParam.executable));
return (this == other || (other instanceof MethodParameter that &&
getContainingClass() == that.getContainingClass() &&
ObjectUtils.nullSafeEquals(this.typeIndexesPerLevel, that.typeIndexesPerLevel) &&
this.nestingLevel == that.nestingLevel &&
this.parameterIndex == that.parameterIndex &&
this.executable.equals(that.executable)));
}
@Override

11
spring-core/src/main/java/org/springframework/core/ResolvableType.java

@ -1577,14 +1577,9 @@ public class ResolvableType implements Serializable { @@ -1577,14 +1577,9 @@ public class ResolvableType implements Serializable {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ParameterizedType otherType)) {
return false;
}
return (otherType.getOwnerType() == null && this.rawType.equals(otherType.getRawType()) &&
Arrays.equals(this.typeArguments, otherType.getActualTypeArguments()));
return (this == other || (other instanceof ParameterizedType that &&
that.getOwnerType() == null && this.rawType.equals(that.getRawType()) &&
Arrays.equals(this.typeArguments, that.getActualTypeArguments())));
}
@Override

17
spring-core/src/main/java/org/springframework/core/convert/Property.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.
@ -260,16 +260,11 @@ public final class Property { @@ -260,16 +260,11 @@ public final class Property {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof Property otherProperty)) {
return false;
}
return (ObjectUtils.nullSafeEquals(this.objectType, otherProperty.objectType) &&
ObjectUtils.nullSafeEquals(this.name, otherProperty.name) &&
ObjectUtils.nullSafeEquals(this.readMethod, otherProperty.readMethod) &&
ObjectUtils.nullSafeEquals(this.writeMethod, otherProperty.writeMethod));
return (this == other || (other instanceof Property that &&
ObjectUtils.nullSafeEquals(this.objectType, that.objectType) &&
ObjectUtils.nullSafeEquals(this.name, that.name) &&
ObjectUtils.nullSafeEquals(this.readMethod, that.readMethod) &&
ObjectUtils.nullSafeEquals(this.writeMethod, that.writeMethod)));
}
@Override

20
spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java

@ -387,7 +387,7 @@ public class GenericConversionService implements ConfigurableConversionService { @@ -387,7 +387,7 @@ public class GenericConversionService implements ConfigurableConversionService {
@Override
public String toString() {
return (this.typeInfo + " : " + this.converter);
return this.typeInfo + " : " + this.converter;
}
}
@ -438,7 +438,7 @@ public class GenericConversionService implements ConfigurableConversionService { @@ -438,7 +438,7 @@ public class GenericConversionService implements ConfigurableConversionService {
@Override
public String toString() {
return (this.typeInfo + " : " + this.converterFactory);
return this.typeInfo + " : " + this.converterFactory;
}
}
@ -459,25 +459,19 @@ public class GenericConversionService implements ConfigurableConversionService { @@ -459,25 +459,19 @@ public class GenericConversionService implements ConfigurableConversionService {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ConverterCacheKey otherKey)) {
return false;
}
return (this.sourceType.equals(otherKey.sourceType)) &&
this.targetType.equals(otherKey.targetType);
return (this == other || (other instanceof ConverterCacheKey that &&
this.sourceType.equals(that.sourceType)) &&
this.targetType.equals(that.targetType));
}
@Override
public int hashCode() {
return (this.sourceType.hashCode() * 29 + this.targetType.hashCode());
return this.sourceType.hashCode() * 29 + this.targetType.hashCode();
}
@Override
public String toString() {
return ("ConverterCacheKey [sourceType = " + this.sourceType +
", targetType = " + this.targetType + "]");
return "ConverterCacheKey [sourceType = " + this.sourceType + ", targetType = " + this.targetType + "]";
}
@Override

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

@ -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.
@ -252,7 +252,7 @@ public abstract class CommandLinePropertySource<T> extends EnumerablePropertySou @@ -252,7 +252,7 @@ public abstract class CommandLinePropertySource<T> extends EnumerablePropertySou
@Override
public final boolean containsProperty(String name) {
if (this.nonOptionArgsPropertyName.equals(name)) {
return !this.getNonOptionArgs().isEmpty();
return !getNonOptionArgs().isEmpty();
}
return this.containsOption(name);
}
@ -270,7 +270,7 @@ public abstract class CommandLinePropertySource<T> extends EnumerablePropertySou @@ -270,7 +270,7 @@ public abstract class CommandLinePropertySource<T> extends EnumerablePropertySou
@Nullable
public final String getProperty(String name) {
if (this.nonOptionArgsPropertyName.equals(name)) {
Collection<String> nonOptionArguments = this.getNonOptionArgs();
Collection<String> nonOptionArguments = getNonOptionArgs();
if (nonOptionArguments.isEmpty()) {
return null;
}
@ -278,7 +278,7 @@ public abstract class CommandLinePropertySource<T> extends EnumerablePropertySou @@ -278,7 +278,7 @@ public abstract class CommandLinePropertySource<T> extends EnumerablePropertySou
return StringUtils.collectionToCommaDelimitedString(nonOptionArguments);
}
}
Collection<String> optionValues = this.getOptionValues(name);
Collection<String> optionValues = getOptionValues(name);
if (optionValues == null) {
return null;
}

13
spring-core/src/main/java/org/springframework/core/io/buffer/DefaultDataBuffer.java

@ -482,15 +482,10 @@ public class DefaultDataBuffer implements DataBuffer { @@ -482,15 +482,10 @@ public class DefaultDataBuffer implements DataBuffer {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof DefaultDataBuffer otherBuffer)) {
return false;
}
return (this.readPosition == otherBuffer.readPosition &&
this.writePosition == otherBuffer.writePosition &&
this.byteBuffer.equals(otherBuffer.byteBuffer));
return (this == other || (other instanceof DefaultDataBuffer that &&
this.readPosition == that.readPosition &&
this.writePosition == that.writePosition &&
this.byteBuffer.equals(that.byteBuffer)));
}
@Override

13
spring-core/src/main/java/org/springframework/core/io/support/EncodedResource.java

@ -184,15 +184,10 @@ public class EncodedResource implements InputStreamSource { @@ -184,15 +184,10 @@ public class EncodedResource implements InputStreamSource {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof EncodedResource otherResource)) {
return false;
}
return (this.resource.equals(otherResource.resource) &&
ObjectUtils.nullSafeEquals(this.charset, otherResource.charset) &&
ObjectUtils.nullSafeEquals(this.encoding, otherResource.encoding));
return (this == other || (other instanceof EncodedResource that &&
this.resource.equals(that.resource) &&
ObjectUtils.nullSafeEquals(this.charset, that.charset) &&
ObjectUtils.nullSafeEquals(this.encoding, that.encoding)));
}
@Override

22
spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java

@ -752,26 +752,20 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen @@ -752,26 +752,20 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen
}
@Override
public String toString() {
return (this.key + "=" + this.value);
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof Map.Entry<?, ?> that &&
ObjectUtils.nullSafeEquals(getKey(), that.getKey()) &&
ObjectUtils.nullSafeEquals(getValue(), that.getValue())));
}
@Override
@SuppressWarnings("rawtypes")
public final boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof Map.Entry otherEntry)) {
return false;
}
return (ObjectUtils.nullSafeEquals(getKey(), otherEntry.getKey()) &&
ObjectUtils.nullSafeEquals(getValue(), otherEntry.getValue()));
public int hashCode() {
return (ObjectUtils.nullSafeHashCode(this.key) ^ ObjectUtils.nullSafeHashCode(this.value));
}
@Override
public final int hashCode() {
return (ObjectUtils.nullSafeHashCode(this.key) ^ ObjectUtils.nullSafeHashCode(this.value));
public String toString() {
return (this.key + "=" + this.value);
}
}

13
spring-core/src/main/java/org/springframework/util/MimeType.java

@ -410,7 +410,7 @@ public class MimeType implements Comparable<MimeType>, Serializable { @@ -410,7 +410,7 @@ public class MimeType implements Comparable<MimeType>, Serializable {
return (thisSuffix.equals(other.getSubtype()) || thisSuffix.equals(otherSuffix));
}
else if (other.isWildcardSubtype() && otherSuffix != null) {
return (this.getSubtype().equals(otherSuffix) || otherSuffix.equals(thisSuffix));
return (getSubtype().equals(otherSuffix) || otherSuffix.equals(thisSuffix));
}
}
}
@ -451,15 +451,10 @@ public class MimeType implements Comparable<MimeType>, Serializable { @@ -451,15 +451,10 @@ public class MimeType implements Comparable<MimeType>, Serializable {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof MimeType otherType)) {
return false;
}
return (this.type.equalsIgnoreCase(otherType.type) &&
return (this == other || (other instanceof MimeType otherType &&
this.type.equalsIgnoreCase(otherType.type) &&
this.subtype.equalsIgnoreCase(otherType.subtype) &&
parametersAreEqual(otherType));
parametersAreEqual(otherType)));
}
/**

14
spring-core/src/main/java/org/springframework/util/comparator/NullSafeComparator.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.
@ -107,16 +107,10 @@ public class NullSafeComparator<T> implements Comparator<T> { @@ -107,16 +107,10 @@ public class NullSafeComparator<T> implements Comparator<T> {
@Override
@SuppressWarnings("unchecked")
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof NullSafeComparator<?> otherComparator)) {
return false;
}
return (this.nonNullComparator.equals(otherComparator.nonNullComparator)
&& this.nullsLow == otherComparator.nullsLow);
return (this == other || (other instanceof NullSafeComparator<?> that &&
this.nonNullComparator.equals(that.nonNullComparator) &&
this.nullsLow == that.nullsLow));
}
@Override

4
spring-core/src/testFixtures/java/org/springframework/core/testfixture/env/MockPropertySource.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.
@ -99,7 +99,7 @@ public class MockPropertySource extends PropertiesPropertySource { @@ -99,7 +99,7 @@ public class MockPropertySource extends PropertiesPropertySource {
* @return this {@link MockPropertySource} instance
*/
public MockPropertySource withProperty(String name, Object value) {
this.setProperty(name, value);
setProperty(name, value);
return this;
}

15
spring-expression/src/main/java/org/springframework/expression/TypedValue.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.
@ -82,16 +82,11 @@ public class TypedValue { @@ -82,16 +82,11 @@ public class TypedValue {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof TypedValue otherTv)) {
return false;
}
// Avoid TypeDescriptor initialization if not necessary
return (ObjectUtils.nullSafeEquals(this.value, otherTv.value) &&
((this.typeDescriptor == null && otherTv.typeDescriptor == null) ||
ObjectUtils.nullSafeEquals(getTypeDescriptor(), otherTv.getTypeDescriptor())));
return (this == other || (other instanceof TypedValue that &&
ObjectUtils.nullSafeEquals(this.value, that.value) &&
((this.typeDescriptor == null && that.typeDescriptor == null) ||
ObjectUtils.nullSafeEquals(getTypeDescriptor(), that.getTypeDescriptor()))));
}
@Override

11
spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java

@ -591,14 +591,9 @@ public class ReflectivePropertyAccessor implements PropertyAccessor { @@ -591,14 +591,9 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof PropertyCacheKey otherKey)) {
return false;
}
return (this.clazz == otherKey.clazz && this.property.equals(otherKey.property) &&
this.targetIsClass == otherKey.targetIsClass);
return (this == other || (other instanceof PropertyCacheKey that &&
this.clazz == that.clazz && this.property.equals(that.property) &&
this.targetIsClass == that.targetIsClass));
}
@Override

19
spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java

@ -615,22 +615,17 @@ public class CachingConnectionFactory extends SingleConnectionFactory { @@ -615,22 +615,17 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ConsumerCacheKey otherKey)) {
return false;
}
return (destinationEquals(otherKey) &&
ObjectUtils.nullSafeEquals(this.selector, otherKey.selector) &&
ObjectUtils.nullSafeEquals(this.noLocal, otherKey.noLocal) &&
ObjectUtils.nullSafeEquals(this.subscription, otherKey.subscription) &&
this.durable == otherKey.durable);
return (this == other || (other instanceof ConsumerCacheKey that &&
destinationEquals(that) &&
ObjectUtils.nullSafeEquals(this.selector, that.selector) &&
ObjectUtils.nullSafeEquals(this.noLocal, that.noLocal) &&
ObjectUtils.nullSafeEquals(this.subscription, that.subscription) &&
this.durable == that.durable));
}
@Override
public int hashCode() {
return (31 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.selector));
return super.hashCode() * 31 + ObjectUtils.nullSafeHashCode(this.selector);
}
@Override

18
spring-jms/src/main/java/org/springframework/jms/support/QosSettings.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.
@ -111,21 +111,15 @@ public class QosSettings { @@ -111,21 +111,15 @@ public class QosSettings {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof QosSettings otherSettings)) {
return false;
}
return (this.deliveryMode == otherSettings.deliveryMode &&
this.priority == otherSettings.priority &&
this.timeToLive == otherSettings.timeToLive);
return (this == other || (other instanceof QosSettings that &&
this.deliveryMode == that.deliveryMode &&
this.priority == that.priority &&
this.timeToLive == that.timeToLive));
}
@Override
public int hashCode() {
return (this.deliveryMode * 31 + this.priority);
return this.deliveryMode * 31 + this.priority;
}
@Override

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

@ -532,14 +532,9 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati @@ -532,14 +532,9 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof SimpSubscription otherSubscription)) {
return false;
}
return (getId().equals(otherSubscription.getId()) &&
ObjectUtils.nullSafeEquals(getSession(), otherSubscription.getSession()));
return (this == other || (other instanceof SimpSubscription that &&
getId().equals(that.getId()) &&
ObjectUtils.nullSafeEquals(getSession(), that.getSession())));
}
@Override

11
spring-messaging/src/main/java/org/springframework/messaging/support/GenericMessage.java

@ -90,20 +90,15 @@ public class GenericMessage<T> implements Message<T>, Serializable { @@ -90,20 +90,15 @@ public class GenericMessage<T> implements Message<T>, Serializable {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof GenericMessage<?> otherMsg)) {
return false;
}
// Using nullSafeEquals for proper array equals comparisons
return (ObjectUtils.nullSafeEquals(this.payload, otherMsg.payload) && this.headers.equals(otherMsg.headers));
return (this == other || (other instanceof GenericMessage<?> that &&
ObjectUtils.nullSafeEquals(this.payload, that.payload) && this.headers.equals(that.headers)));
}
@Override
public int hashCode() {
// Using nullSafeHashCode for proper array hashCode handling
return (ObjectUtils.nullSafeHashCode(this.payload) * 23 + this.headers.hashCode());
return ObjectUtils.nullSafeHashCode(this.payload) * 23 + this.headers.hashCode();
}
@Override

11
spring-messaging/src/test/java/org/springframework/messaging/simp/user/TestSimpSubscription.java

@ -59,14 +59,9 @@ public class TestSimpSubscription implements SimpSubscription { @@ -59,14 +59,9 @@ public class TestSimpSubscription implements SimpSubscription {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof SimpSubscription otherSubscription)) {
return false;
}
return (ObjectUtils.nullSafeEquals(getSession(), otherSubscription.getSession()) &&
this.id.equals(otherSubscription.getId()));
return (this == other || (other instanceof SimpSubscription that &&
ObjectUtils.nullSafeEquals(getSession(), that.getSession()) &&
this.id.equals(that.getId())));
}
@Override

4
spring-test/src/main/java/org/springframework/mock/env/MockEnvironment.java vendored

@ -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.
@ -54,7 +54,7 @@ public class MockEnvironment extends AbstractEnvironment { @@ -54,7 +54,7 @@ public class MockEnvironment extends AbstractEnvironment {
* @see MockPropertySource#withProperty
*/
public MockEnvironment withProperty(String key, String value) {
this.setProperty(key, value);
setProperty(key, value);
return this;
}

2
spring-test/src/main/java/org/springframework/mock/env/MockPropertySource.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 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.

25
spring-test/src/main/java/org/springframework/test/context/ContextConfigurationAttributes.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.
@ -334,20 +334,15 @@ public class ContextConfigurationAttributes { @@ -334,20 +334,15 @@ public class ContextConfigurationAttributes {
*/
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ContextConfigurationAttributes otherAttr)) {
return false;
}
return (ObjectUtils.nullSafeEquals(this.declaringClass, otherAttr.declaringClass) &&
Arrays.equals(this.classes, otherAttr.classes)) &&
Arrays.equals(this.locations, otherAttr.locations) &&
this.inheritLocations == otherAttr.inheritLocations &&
Arrays.equals(this.initializers, otherAttr.initializers) &&
this.inheritInitializers == otherAttr.inheritInitializers &&
ObjectUtils.nullSafeEquals(this.name, otherAttr.name) &&
ObjectUtils.nullSafeEquals(this.contextLoaderClass, otherAttr.contextLoaderClass);
return (this == other || (other instanceof ContextConfigurationAttributes that &&
ObjectUtils.nullSafeEquals(this.declaringClass, that.declaringClass) &&
Arrays.equals(this.classes, that.classes)) &&
Arrays.equals(this.locations, that.locations) &&
this.inheritLocations == that.inheritLocations &&
Arrays.equals(this.initializers, that.initializers) &&
this.inheritInitializers == that.inheritInitializers &&
ObjectUtils.nullSafeEquals(this.name, that.name) &&
ObjectUtils.nullSafeEquals(this.contextLoaderClass, that.contextLoaderClass));
}
/**

4
spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 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.
@ -112,7 +112,7 @@ public class XpathExpectationsHelper { @@ -112,7 +112,7 @@ public class XpathExpectationsHelper {
Document document = parseXmlByteArray(content, encoding);
NodeList nodeList = evaluateXpath(document, XPathConstants.NODESET, NodeList.class);
MatcherAssert.assertThat("XPath " + this.getXpathExpression(), nodeList, matcher);
MatcherAssert.assertThat("XPath " + getXpathExpression(), nodeList, matcher);
}
/**

13
spring-test/src/test/java/org/springframework/test/web/Person.java

@ -68,15 +68,10 @@ public class Person { @@ -68,15 +68,10 @@ public class Person {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof Person otherPerson)) {
return false;
}
return (ObjectUtils.nullSafeEquals(this.name, otherPerson.name) &&
ObjectUtils.nullSafeEquals(this.someDouble, otherPerson.someDouble) &&
ObjectUtils.nullSafeEquals(this.someBoolean, otherPerson.someBoolean));
return (this == other || (other instanceof Person that &&
ObjectUtils.nullSafeEquals(this.name, that.name) &&
ObjectUtils.nullSafeEquals(this.someDouble, that.someDouble) &&
ObjectUtils.nullSafeEquals(this.someBoolean, that.someBoolean)));
}
@Override

11
spring-tx/src/main/java/org/springframework/transaction/interceptor/MatchAlwaysTransactionAttributeSource.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.
@ -65,13 +65,8 @@ public class MatchAlwaysTransactionAttributeSource implements TransactionAttribu @@ -65,13 +65,8 @@ public class MatchAlwaysTransactionAttributeSource implements TransactionAttribu
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof MatchAlwaysTransactionAttributeSource otherTas)) {
return false;
}
return ObjectUtils.nullSafeEquals(this.transactionAttribute, otherTas.transactionAttribute);
return (this == other || (other instanceof MatchAlwaysTransactionAttributeSource that &&
ObjectUtils.nullSafeEquals(this.transactionAttribute, that.transactionAttribute)));
}
@Override

11
spring-tx/src/main/java/org/springframework/transaction/interceptor/RollbackRuleAttribute.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.
@ -180,13 +180,8 @@ public class RollbackRuleAttribute implements Serializable{ @@ -180,13 +180,8 @@ public class RollbackRuleAttribute implements Serializable{
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof RollbackRuleAttribute rhs)) {
return false;
}
return this.exceptionPattern.equals(rhs.exceptionPattern);
return (this == other || (other instanceof RollbackRuleAttribute that &&
this.exceptionPattern.equals(that.exceptionPattern)));
}
@Override

23
spring-web/src/main/java/org/springframework/http/ContentDisposition.java

@ -227,20 +227,15 @@ public final class ContentDisposition { @@ -227,20 +227,15 @@ public final class ContentDisposition {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ContentDisposition otherCd)) {
return false;
}
return (ObjectUtils.nullSafeEquals(this.type, otherCd.type) &&
ObjectUtils.nullSafeEquals(this.name, otherCd.name) &&
ObjectUtils.nullSafeEquals(this.filename, otherCd.filename) &&
ObjectUtils.nullSafeEquals(this.charset, otherCd.charset) &&
ObjectUtils.nullSafeEquals(this.size, otherCd.size) &&
ObjectUtils.nullSafeEquals(this.creationDate, otherCd.creationDate)&&
ObjectUtils.nullSafeEquals(this.modificationDate, otherCd.modificationDate)&&
ObjectUtils.nullSafeEquals(this.readDate, otherCd.readDate));
return (this == other || (other instanceof ContentDisposition that &&
ObjectUtils.nullSafeEquals(this.type, that.type) &&
ObjectUtils.nullSafeEquals(this.name, that.name) &&
ObjectUtils.nullSafeEquals(this.filename, that.filename) &&
ObjectUtils.nullSafeEquals(this.charset, that.charset) &&
ObjectUtils.nullSafeEquals(this.size, that.size) &&
ObjectUtils.nullSafeEquals(this.creationDate, that.creationDate)&&
ObjectUtils.nullSafeEquals(this.modificationDate, that.modificationDate)&&
ObjectUtils.nullSafeEquals(this.readDate, that.readDate)));
}
@Override

17
spring-web/src/main/java/org/springframework/http/HttpCookie.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.
@ -57,19 +57,14 @@ public class HttpCookie { @@ -57,19 +57,14 @@ public class HttpCookie {
@Override
public int hashCode() {
return this.name.hashCode();
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof HttpCookie that &&
this.name.equalsIgnoreCase(that.getName())));
}
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof HttpCookie otherCookie)) {
return false;
}
return (this.name.equalsIgnoreCase(otherCookie.getName()));
public int hashCode() {
return this.name.hashCode();
}
@Override

22
spring-web/src/main/java/org/springframework/http/HttpRange.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.
@ -269,14 +269,9 @@ public abstract class HttpRange { @@ -269,14 +269,9 @@ public abstract class HttpRange {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ByteRange otherRange)) {
return false;
}
return (this.firstPos == otherRange.firstPos &&
ObjectUtils.nullSafeEquals(this.lastPos, otherRange.lastPos));
return (this == other || (other instanceof ByteRange that &&
this.firstPos == that.firstPos &&
ObjectUtils.nullSafeEquals(this.lastPos, that.lastPos)));
}
@Override
@ -331,13 +326,8 @@ public abstract class HttpRange { @@ -331,13 +326,8 @@ public abstract class HttpRange {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof SuffixByteRange otherRange)) {
return false;
}
return (this.suffixLength == otherRange.suffixLength);
return (this == other || (other instanceof SuffixByteRange that &&
this.suffixLength == that.suffixLength));
}
@Override

19
spring-web/src/main/java/org/springframework/http/ProblemDetail.java

@ -233,18 +233,13 @@ public class ProblemDetail { @@ -233,18 +233,13 @@ public class ProblemDetail {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ProblemDetail otherDetail)) {
return false;
}
return (getType().equals(otherDetail.getType()) &&
ObjectUtils.nullSafeEquals(getTitle(), otherDetail.getTitle()) &&
this.status == otherDetail.status &&
ObjectUtils.nullSafeEquals(this.detail, otherDetail.detail) &&
ObjectUtils.nullSafeEquals(this.instance, otherDetail.instance) &&
ObjectUtils.nullSafeEquals(this.properties, otherDetail.properties));
return (this == other || (other instanceof ProblemDetail that &&
getType().equals(that.getType()) &&
ObjectUtils.nullSafeEquals(getTitle(), that.getTitle()) &&
this.status == that.status &&
ObjectUtils.nullSafeEquals(this.detail, that.detail) &&
ObjectUtils.nullSafeEquals(this.instance, that.instance) &&
ObjectUtils.nullSafeEquals(this.properties, that.properties)));
}
@Override

15
spring-web/src/main/java/org/springframework/http/ResponseCookie.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.
@ -144,15 +144,10 @@ public final class ResponseCookie extends HttpCookie { @@ -144,15 +144,10 @@ public final class ResponseCookie extends HttpCookie {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ResponseCookie otherCookie)) {
return false;
}
return (getName().equalsIgnoreCase(otherCookie.getName()) &&
ObjectUtils.nullSafeEquals(this.path, otherCookie.getPath()) &&
ObjectUtils.nullSafeEquals(this.domain, otherCookie.getDomain()));
return (this == other ||(other instanceof ResponseCookie that &&
getName().equalsIgnoreCase(that.getName()) &&
ObjectUtils.nullSafeEquals(this.path, that.getPath()) &&
ObjectUtils.nullSafeEquals(this.domain, that.getDomain())));
}
@Override

4
spring-web/src/main/java/org/springframework/http/client/observation/ClientRequestObservationContext.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.
@ -41,7 +41,7 @@ public class ClientRequestObservationContext extends RequestReplySenderContext<C @@ -41,7 +41,7 @@ public class ClientRequestObservationContext extends RequestReplySenderContext<C
*/
public ClientRequestObservationContext(ClientHttpRequest request) {
super(ClientRequestObservationContext::setRequestHeader);
this.setCarrier(request);
setCarrier(request);
}
private static void setRequestHeader(@Nullable ClientHttpRequest request, String name, String value) {

2
spring-web/src/main/java/org/springframework/http/client/reactive/ReactorNetty2ClientHttpResponse.java

@ -160,7 +160,7 @@ class ReactorNetty2ClientHttpResponse implements ClientHttpResponse { @@ -160,7 +160,7 @@ class ReactorNetty2ClientHttpResponse implements ClientHttpResponse {
}
private boolean mayHaveBody(HttpMethod method) {
int code = this.getStatusCode().value();
int code = getStatusCode().value();
return !((code >= 100 && code < 200) || code == 204 || code == 205 ||
method.equals(HttpMethod.HEAD) || getHeaders().getContentLength() == 0);
}

9
spring-web/src/main/java/org/springframework/web/context/support/ServletContextResource.java

@ -244,13 +244,8 @@ public class ServletContextResource extends AbstractFileResolvingResource implem @@ -244,13 +244,8 @@ public class ServletContextResource extends AbstractFileResolvingResource implem
*/
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ServletContextResource otherRes)) {
return false;
}
return (this.servletContext.equals(otherRes.servletContext) && this.path.equals(otherRes.path));
return (this == other || (other instanceof ServletContextResource that &&
this.path.equals(that.path) && this.servletContext.equals(that.servletContext)));
}
/**

4
spring-web/src/main/java/org/springframework/web/filter/DelegatingFilterProxy.java

@ -161,10 +161,10 @@ public class DelegatingFilterProxy extends GenericFilterBean { @@ -161,10 +161,10 @@ public class DelegatingFilterProxy extends GenericFilterBean {
*/
public DelegatingFilterProxy(String targetBeanName, @Nullable WebApplicationContext wac) {
Assert.hasText(targetBeanName, "Target Filter bean name must not be null or empty");
this.setTargetBeanName(targetBeanName);
setTargetBeanName(targetBeanName);
this.webApplicationContext = wac;
if (wac != null) {
this.setEnvironment(wac.getEnvironment());
setEnvironment(wac.getEnvironment());
}
}

11
spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.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.
@ -257,13 +257,8 @@ public class ControllerAdviceBean implements Ordered { @@ -257,13 +257,8 @@ public class ControllerAdviceBean implements Ordered {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ControllerAdviceBean otherAdvice)) {
return false;
}
return (this.beanOrName.equals(otherAdvice.beanOrName) && this.beanFactory == otherAdvice.beanFactory);
return (this == other || (other instanceof ControllerAdviceBean that &&
this.beanOrName.equals(that.beanOrName) && this.beanFactory == that.beanFactory));
}
@Override

4
spring-web/src/main/java/org/springframework/web/server/session/HeaderWebSessionIdResolver.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.
@ -74,7 +74,7 @@ public class HeaderWebSessionIdResolver implements WebSessionIdResolver { @@ -74,7 +74,7 @@ public class HeaderWebSessionIdResolver implements WebSessionIdResolver {
@Override
public void expireSession(ServerWebExchange exchange) {
this.setSessionId(exchange, "");
setSessionId(exchange, "");
}
}

23
spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.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.
@ -554,19 +554,14 @@ final class HierarchicalUriComponents extends UriComponents { @@ -554,19 +554,14 @@ final class HierarchicalUriComponents extends UriComponents {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof HierarchicalUriComponents otherComp)) {
return false;
}
return (ObjectUtils.nullSafeEquals(getScheme(), otherComp.getScheme()) &&
ObjectUtils.nullSafeEquals(getUserInfo(), otherComp.getUserInfo()) &&
ObjectUtils.nullSafeEquals(getHost(), otherComp.getHost()) &&
getPort() == otherComp.getPort() &&
this.path.equals(otherComp.path) &&
this.queryParams.equals(otherComp.queryParams) &&
ObjectUtils.nullSafeEquals(getFragment(), otherComp.getFragment()));
return (this == other || (other instanceof HierarchicalUriComponents that &&
ObjectUtils.nullSafeEquals(getScheme(), that.getScheme()) &&
ObjectUtils.nullSafeEquals(getUserInfo(), that.getUserInfo()) &&
ObjectUtils.nullSafeEquals(getHost(), that.getHost()) &&
getPort() == that.getPort() &&
this.path.equals(that.path) &&
this.queryParams.equals(that.queryParams) &&
ObjectUtils.nullSafeEquals(getFragment(), that.getFragment())));
}
@Override

15
spring-web/src/main/java/org/springframework/web/util/OpaqueUriComponents.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.
@ -158,15 +158,10 @@ final class OpaqueUriComponents extends UriComponents { @@ -158,15 +158,10 @@ final class OpaqueUriComponents extends UriComponents {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof OpaqueUriComponents otherComp)) {
return false;
}
return (ObjectUtils.nullSafeEquals(getScheme(), otherComp.getScheme()) &&
ObjectUtils.nullSafeEquals(this.ssp, otherComp.ssp) &&
ObjectUtils.nullSafeEquals(getFragment(), otherComp.getFragment()));
return (this == other || (other instanceof OpaqueUriComponents that &&
ObjectUtils.nullSafeEquals(getScheme(), that.getScheme()) &&
ObjectUtils.nullSafeEquals(this.ssp, that.ssp) &&
ObjectUtils.nullSafeEquals(getFragment(), that.getFragment())));
}
@Override

10
spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java

@ -432,12 +432,10 @@ public class PathPattern implements Comparable<PathPattern> { @@ -432,12 +432,10 @@ public class PathPattern implements Comparable<PathPattern> {
@Override
public boolean equals(@Nullable Object other) {
if (!(other instanceof PathPattern otherPattern)) {
return false;
}
return (this.patternString.equals(otherPattern.getPatternString()) &&
getSeparator() == otherPattern.getSeparator() &&
this.caseSensitive == otherPattern.caseSensitive);
return (this == other || (other instanceof PathPattern that &&
this.patternString.equals(that.getPatternString()) &&
getSeparator() == that.getSeparator() &&
this.caseSensitive == that.caseSensitive));
}
@Override

13
spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctions.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.
@ -167,18 +167,13 @@ public abstract class ExchangeFilterFunctions { @@ -167,18 +167,13 @@ public abstract class ExchangeFilterFunctions {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof Credentials otherCred)) {
return false;
}
return (this.username.equals(otherCred.username) && this.password.equals(otherCred.password));
return (this == other ||(other instanceof Credentials that &&
this.username.equals(that.username) && this.password.equals(that.password)));
}
@Override
public int hashCode() {
return 31 * this.username.hashCode() + this.password.hashCode();
return this.username.hashCode() * 31 + this.password.hashCode();
}
}

9
spring-webflux/src/main/java/org/springframework/web/reactive/resource/CssLinkResourceTransformer.java

@ -282,13 +282,8 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport { @@ -282,13 +282,8 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ContentChunkInfo otherCci)) {
return false;
}
return (this.start == otherCci.start && this.end == otherCci.end);
return (this == other || (other instanceof ContentChunkInfo that &&
this.start == that.start && this.end == that.end));
}
@Override

4
spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/AbstractMediaTypeExpression.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.
@ -95,7 +95,7 @@ abstract class AbstractMediaTypeExpression implements Comparable<AbstractMediaTy @@ -95,7 +95,7 @@ abstract class AbstractMediaTypeExpression implements Comparable<AbstractMediaTy
@Override
public int compareTo(AbstractMediaTypeExpression other) {
MediaType mediaType1 = this.getMediaType();
MediaType mediaType1 = getMediaType();
MediaType mediaType2 = other.getMediaType();
if (mediaType1.isMoreSpecific(mediaType2)) {
return -1;

21
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.java

@ -340,19 +340,14 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping @@ -340,19 +340,14 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof RequestMappingInfo otherInfo)) {
return false;
}
return (this.patternsCondition.equals(otherInfo.patternsCondition) &&
this.methodsCondition.equals(otherInfo.methodsCondition) &&
this.paramsCondition.equals(otherInfo.paramsCondition) &&
this.headersCondition.equals(otherInfo.headersCondition) &&
this.consumesCondition.equals(otherInfo.consumesCondition) &&
this.producesCondition.equals(otherInfo.producesCondition) &&
this.customConditionHolder.equals(otherInfo.customConditionHolder));
return (this == other || (other instanceof RequestMappingInfo that &&
this.patternsCondition.equals(that.patternsCondition) &&
this.methodsCondition.equals(that.methodsCondition) &&
this.paramsCondition.equals(that.paramsCondition) &&
this.headersCondition.equals(that.headersCondition) &&
this.consumesCondition.equals(that.consumesCondition) &&
this.producesCondition.equals(that.producesCondition) &&
this.customConditionHolder.equals(that.customConditionHolder)));
}
@Override

11
spring-webflux/src/main/java/org/springframework/web/reactive/socket/CloseStatus.java

@ -224,14 +224,9 @@ public final class CloseStatus { @@ -224,14 +224,9 @@ public final class CloseStatus {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof CloseStatus otherStatus)) {
return false;
}
return (this.code == otherStatus.code &&
ObjectUtils.nullSafeEquals(this.reason, otherStatus.reason));
return (this == other || (other instanceof CloseStatus that &&
this.code == that.code &&
ObjectUtils.nullSafeEquals(this.reason, that.reason)));
}
@Override

13
spring-webflux/src/main/java/org/springframework/web/reactive/socket/WebSocketMessage.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.
@ -157,14 +157,9 @@ public class WebSocketMessage { @@ -157,14 +157,9 @@ public class WebSocketMessage {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof WebSocketMessage otherMessage)) {
return false;
}
return (this.type.equals(otherMessage.type) &&
ObjectUtils.nullSafeEquals(this.payload, otherMessage.payload));
return (this == other || (other instanceof WebSocketMessage that &&
this.type.equals(that.type) &&
ObjectUtils.nullSafeEquals(this.payload, that.payload)));
}
@Override

15
spring-webmvc/src/main/java/org/springframework/web/servlet/FlashMap.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.
@ -162,15 +162,10 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl @@ -162,15 +162,10 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof FlashMap otherFlashMap)) {
return false;
}
return (super.equals(otherFlashMap) &&
ObjectUtils.nullSafeEquals(this.targetRequestPath, otherFlashMap.targetRequestPath) &&
this.targetRequestParams.equals(otherFlashMap.targetRequestParams));
return (this == other || (other instanceof FlashMap that &&
super.equals(other) &&
ObjectUtils.nullSafeEquals(this.targetRequestPath, that.targetRequestPath) &&
this.targetRequestParams.equals(that.targetRequestParams)));
}
@Override

4
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractMediaTypeExpression.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.
@ -68,7 +68,7 @@ abstract class AbstractMediaTypeExpression implements MediaTypeExpression, Compa @@ -68,7 +68,7 @@ abstract class AbstractMediaTypeExpression implements MediaTypeExpression, Compa
@Override
public int compareTo(AbstractMediaTypeExpression other) {
MediaType mediaType1 = this.getMediaType();
MediaType mediaType1 = getMediaType();
MediaType mediaType2 = other.getMediaType();
if (mediaType1.isMoreSpecific(mediaType2)) {
return -1;

21
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java

@ -475,19 +475,14 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping @@ -475,19 +475,14 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof RequestMappingInfo otherInfo)) {
return false;
}
return (getActivePatternsCondition().equals(otherInfo.getActivePatternsCondition()) &&
this.methodsCondition.equals(otherInfo.methodsCondition) &&
this.paramsCondition.equals(otherInfo.paramsCondition) &&
this.headersCondition.equals(otherInfo.headersCondition) &&
this.consumesCondition.equals(otherInfo.consumesCondition) &&
this.producesCondition.equals(otherInfo.producesCondition) &&
this.customConditionHolder.equals(otherInfo.customConditionHolder));
return (this == other || (other instanceof RequestMappingInfo that &&
getActivePatternsCondition().equals(that.getActivePatternsCondition()) &&
this.methodsCondition.equals(that.methodsCondition) &&
this.paramsCondition.equals(that.paramsCondition) &&
this.headersCondition.equals(that.headersCondition) &&
this.consumesCondition.equals(that.consumesCondition) &&
this.producesCondition.equals(that.producesCondition) &&
this.customConditionHolder.equals(that.customConditionHolder)));
}
@Override

11
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CssLinkResourceTransformer.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.
@ -231,13 +231,8 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport { @@ -231,13 +231,8 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ContentChunkInfo otherCci)) {
return false;
}
return (this.start == otherCci.start && this.end == otherCci.end);
return (this == other || (other instanceof ContentChunkInfo that &&
this.start == that.start && this.end == that.end));
}
@Override

16
spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateView.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.
@ -234,7 +234,7 @@ public class ScriptTemplateView extends AbstractUrlBasedView { @@ -234,7 +234,7 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
if (this.renderFunction == null && viewConfig.getRenderFunction() != null) {
this.renderFunction = viewConfig.getRenderFunction();
}
if (this.getContentType() == null) {
if (getContentType() == null) {
setContentType(viewConfig.getContentType() != null ? viewConfig.getContentType() : DEFAULT_CONTENT_TYPE);
}
if (this.charset == null) {
@ -467,18 +467,14 @@ public class ScriptTemplateView extends AbstractUrlBasedView { @@ -467,18 +467,14 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof EngineKey otherKey)) {
return false;
}
return (this.engineName.equals(otherKey.engineName) && Arrays.equals(this.scripts, otherKey.scripts));
return (this == other || (other instanceof EngineKey that &&
this.engineName.equals(that.engineName) &&
Arrays.equals(this.scripts, that.scripts)));
}
@Override
public int hashCode() {
return (this.engineName.hashCode() * 29 + Arrays.hashCode(this.scripts));
return this.engineName.hashCode() * 29 + Arrays.hashCode(this.scripts);
}
}

10
spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ItemPet.java

@ -19,6 +19,7 @@ package org.springframework.web.servlet.tags.form; @@ -19,6 +19,7 @@ package org.springframework.web.servlet.tags.form;
import java.beans.PropertyEditorSupport;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
* @author Juergen Hoeller
@ -45,13 +46,8 @@ public class ItemPet { @@ -45,13 +46,8 @@ public class ItemPet {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ItemPet otherPet)) {
return false;
}
return (this.name != null && this.name.equals(otherPet.getName()));
return (this == other || (other instanceof ItemPet that &&
ObjectUtils.nullSafeEquals(this.name, that.getName())));
}
@Override

11
spring-websocket/src/main/java/org/springframework/web/socket/AbstractWebSocketMessage.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.
@ -76,13 +76,8 @@ public abstract class AbstractWebSocketMessage<T> implements WebSocketMessage<T> @@ -76,13 +76,8 @@ public abstract class AbstractWebSocketMessage<T> implements WebSocketMessage<T>
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AbstractWebSocketMessage<?> otherMessage)) {
return false;
}
return ObjectUtils.nullSafeEquals(this.payload, otherMessage.payload);
return (this == other || (other instanceof AbstractWebSocketMessage<?> that &&
ObjectUtils.nullSafeEquals(this.payload, that.payload)));
}
@Override

9
spring-websocket/src/main/java/org/springframework/web/socket/CloseStatus.java

@ -207,13 +207,8 @@ public final class CloseStatus implements Serializable { @@ -207,13 +207,8 @@ public final class CloseStatus implements Serializable {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof CloseStatus otherStatus)) {
return false;
}
return (this.code == otherStatus.code && ObjectUtils.nullSafeEquals(this.reason, otherStatus.reason));
return (this == other || (other instanceof CloseStatus that &&
this.code == that.code && ObjectUtils.nullSafeEquals(this.reason, that.reason)));
}
@Override

9
spring-websocket/src/main/java/org/springframework/web/socket/WebSocketHttpHeaders.java

@ -309,13 +309,8 @@ public class WebSocketHttpHeaders extends HttpHeaders { @@ -309,13 +309,8 @@ public class WebSocketHttpHeaders extends HttpHeaders {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof WebSocketHttpHeaders otherHeaders)) {
return false;
}
return this.headers.equals(otherHeaders.headers);
return (this == other || (other instanceof WebSocketHttpHeaders that &&
this.headers.equals(that.headers)));
}
@Override

19
spring-websocket/src/main/java/org/springframework/web/socket/messaging/DefaultSimpUserRegistry.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.
@ -238,8 +238,7 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati @@ -238,8 +238,7 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
@Override
public boolean equals(@Nullable Object other) {
return (this == other ||
(other instanceof SimpUser otherSimpUser && getName().equals(otherSimpUser.getName())));
return (this == other || (other instanceof SimpUser that && getName().equals(that.getName())));
}
@Override
@ -294,8 +293,7 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati @@ -294,8 +293,7 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
@Override
public boolean equals(@Nullable Object other) {
return (this == other ||
(other instanceof SimpSubscription otherSubscription && getId().equals(otherSubscription.getId())));
return (this == other || (other instanceof SimpSubscription that && getId().equals(that.getId())));
}
@Override
@ -344,14 +342,9 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati @@ -344,14 +342,9 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof SimpSubscription otherSubscription)) {
return false;
}
return (getId().equals(otherSubscription.getId()) &&
getSession().getId().equals(otherSubscription.getSession().getId()));
return (this == other || (other instanceof SimpSubscription that &&
getId().equals(that.getId()) &&
getSession().getId().equals(that.getSession().getId())));
}
@Override

9
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/SockJsFrame.java

@ -122,13 +122,8 @@ public class SockJsFrame { @@ -122,13 +122,8 @@ public class SockJsFrame {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof SockJsFrame otherFrame)) {
return false;
}
return (this.type.equals(otherFrame.type) && this.content.equals(otherFrame.content));
return (this == other || (other instanceof SockJsFrame that &&
this.type.equals(that.type) && this.content.equals(that.content)));
}
@Override

Loading…
Cancel
Save