Browse Source

Apply "instanceof pattern matching" Eclipse clean-up in spring-aop

This commit also applies additional clean-up tasks such as the following.

- final fields

This has only been applied to `src/main/java`.
pull/27562/head
Sam Brannen 4 years ago
parent
commit
07cd6ab761
  1. 6
      spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java
  2. 6
      spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverer.java
  3. 3
      spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAroundAdvice.java
  4. 3
      spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java
  5. 3
      spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJPointcutAdvisor.java
  6. 3
      spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java
  7. 3
      spring-aop/src/main/java/org/springframework/aop/config/AspectJAutoProxyBeanDefinitionParser.java
  8. 2
      spring-aop/src/main/java/org/springframework/aop/config/ConfigBeanDefinitionParser.java
  9. 3
      spring-aop/src/main/java/org/springframework/aop/config/ScopedProxyBeanDefinitionDecorator.java
  10. 3
      spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java
  11. 3
      spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java
  12. 3
      spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java
  13. 11
      spring-aop/src/main/java/org/springframework/aop/framework/DefaultAdvisorChainFactory.java
  14. 3
      spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java
  15. 6
      spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java
  16. 3
      spring-aop/src/main/java/org/springframework/aop/framework/adapter/DefaultAdvisorAdapterRegistry.java
  17. 9
      spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisors.java
  18. 4
      spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyFactoryBean.java
  19. 3
      spring-aop/src/main/java/org/springframework/aop/support/AbstractPointcutAdvisor.java
  20. 3
      spring-aop/src/main/java/org/springframework/aop/support/AbstractRegexpMethodPointcut.java
  21. 3
      spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java
  22. 3
      spring-aop/src/main/java/org/springframework/aop/support/ComposablePointcut.java
  23. 3
      spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java
  24. 3
      spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java
  25. 4
      spring-aop/src/main/java/org/springframework/aop/support/DelegatePerTargetObjectIntroductionInterceptor.java
  26. 9
      spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java
  27. 3
      spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationClassFilter.java
  28. 6
      spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMatchingPointcut.java
  29. 3
      spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMethodMatcher.java
  30. 3
      spring-aop/src/main/java/org/springframework/aop/target/EmptyTargetSource.java
  31. 3
      spring-aop/src/main/java/org/springframework/aop/target/SingletonTargetSource.java

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

@ -78,10 +78,9 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence @@ -78,10 +78,9 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
*/
public static JoinPoint currentJoinPoint() {
MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation();
if (!(mi instanceof ProxyMethodInvocation)) {
if (!(mi instanceof ProxyMethodInvocation pmi)) {
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
}
ProxyMethodInvocation pmi = (ProxyMethodInvocation) mi;
JoinPoint jp = (JoinPoint) pmi.getUserAttribute(JOIN_POINT_KEY);
if (jp == null) {
jp = new MethodInvocationProceedingJoinPoint(pmi);
@ -714,10 +713,9 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence @@ -714,10 +713,9 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
if (this == other) {
return true;
}
if (!(other instanceof AdviceExcludingMethodMatcher)) {
if (!(other instanceof AdviceExcludingMethodMatcher otherMm)) {
return false;
}
AdviceExcludingMethodMatcher otherMm = (AdviceExcludingMethodMatcher) other;
return this.adviceMethod.equals(otherMm.adviceMethod);
}

6
spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverer.java

@ -158,7 +158,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov @@ -158,7 +158,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
/** The pointcut expression associated with the advice, as a simple String. */
@Nullable
private String pointcutExpression;
private final String pointcutExpression;
private boolean raiseExceptions;
@ -759,10 +759,10 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov @@ -759,10 +759,10 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
*/
private static class PointcutBody {
private int numTokensConsumed;
private final int numTokensConsumed;
@Nullable
private String text;
private final String text;
public PointcutBody(int tokens, @Nullable String text) {
this.numTokensConsumed = tokens;

3
spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAroundAdvice.java

@ -63,10 +63,9 @@ public class AspectJAroundAdvice extends AbstractAspectJAdvice implements Method @@ -63,10 +63,9 @@ public class AspectJAroundAdvice extends AbstractAspectJAdvice implements Method
@Override
@Nullable
public Object invoke(MethodInvocation mi) throws Throwable {
if (!(mi instanceof ProxyMethodInvocation)) {
if (!(mi instanceof ProxyMethodInvocation pmi)) {
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
}
ProxyMethodInvocation pmi = (ProxyMethodInvocation) mi;
ProceedingJoinPoint pjp = lazyGetProceedingJoinPoint(pmi);
JoinPointMatch jpm = getJoinPointMatch(pmi);
return invokeAdviceMethod(pjp, jpm, null, null);

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

@ -523,10 +523,9 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut @@ -523,10 +523,9 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
if (this == other) {
return true;
}
if (!(other instanceof AspectJExpressionPointcut)) {
if (!(other instanceof AspectJExpressionPointcut otherPc)) {
return false;
}
AspectJExpressionPointcut otherPc = (AspectJExpressionPointcut) other;
return ObjectUtils.nullSafeEquals(this.getExpression(), otherPc.getExpression()) &&
ObjectUtils.nullSafeEquals(this.pointcutDeclarationScope, otherPc.pointcutDeclarationScope) &&
ObjectUtils.nullSafeEquals(this.pointcutParameterNames, otherPc.pointcutParameterNames) &&

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

@ -97,10 +97,9 @@ public class AspectJPointcutAdvisor implements PointcutAdvisor, Ordered { @@ -97,10 +97,9 @@ public class AspectJPointcutAdvisor implements PointcutAdvisor, Ordered {
if (this == other) {
return true;
}
if (!(other instanceof AspectJPointcutAdvisor)) {
if (!(other instanceof AspectJPointcutAdvisor otherAdvisor)) {
return false;
}
AspectJPointcutAdvisor otherAdvisor = (AspectJPointcutAdvisor) other;
return this.advice.equals(otherAdvisor.advice);
}

3
spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java

@ -214,8 +214,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac @@ -214,8 +214,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
private String resolveExpression(A annotation) {
for (String attributeName : EXPRESSION_ATTRIBUTES) {
Object val = AnnotationUtils.getValue(annotation, attributeName);
if (val instanceof String) {
String str = (String) val;
if (val instanceof String str) {
if (!str.isEmpty()) {
return str;
}

3
spring-aop/src/main/java/org/springframework/aop/config/AspectJAutoProxyBeanDefinitionParser.java

@ -59,8 +59,7 @@ class AspectJAutoProxyBeanDefinitionParser implements BeanDefinitionParser { @@ -59,8 +59,7 @@ class AspectJAutoProxyBeanDefinitionParser implements BeanDefinitionParser {
NodeList childNodes = element.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node node = childNodes.item(i);
if (node instanceof Element) {
Element includeElement = (Element) node;
if (node instanceof Element includeElement) {
TypedStringValue valueHolder = new TypedStringValue(includeElement.getAttribute("name"));
valueHolder.setSource(parserContext.extractSource(includeElement));
includePatterns.add(valueHolder);

2
spring-aop/src/main/java/org/springframework/aop/config/ConfigBeanDefinitionParser.java

@ -93,7 +93,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser { @@ -93,7 +93,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
private static final int POINTCUT_INDEX = 1;
private static final int ASPECT_INSTANCE_FACTORY_INDEX = 2;
private ParseState parseState = new ParseState();
private final ParseState parseState = new ParseState();
@Override

3
spring-aop/src/main/java/org/springframework/aop/config/ScopedProxyBeanDefinitionDecorator.java

@ -42,8 +42,7 @@ class ScopedProxyBeanDefinitionDecorator implements BeanDefinitionDecorator { @@ -42,8 +42,7 @@ class ScopedProxyBeanDefinitionDecorator implements BeanDefinitionDecorator {
@Override
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
boolean proxyTargetClass = true;
if (node instanceof Element) {
Element ele = (Element) node;
if (node instanceof Element ele) {
if (ele.hasAttribute(PROXY_TARGET_CLASS)) {
proxyTargetClass = Boolean.parseBoolean(ele.getAttribute(PROXY_TARGET_CLASS));
}

3
spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java

@ -69,8 +69,7 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyProcessorSu @@ -69,8 +69,7 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyProcessorSu
return bean;
}
if (bean instanceof Advised) {
Advised advised = (Advised) bean;
if (bean instanceof Advised advised) {
if (!advised.isFrozen() && isEligible(AopUtils.getTargetClass(bean))) {
// Add our local Advisor to the existing proxy's Advisor chain...
if (this.beforeExistingAdvisors) {

3
spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java

@ -283,8 +283,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised { @@ -283,8 +283,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
}
Advisor advisor = this.advisors.remove(index);
if (advisor instanceof IntroductionAdvisor) {
IntroductionAdvisor ia = (IntroductionAdvisor) advisor;
if (advisor instanceof IntroductionAdvisor ia) {
// We need to remove introduction interfaces.
for (Class<?> ifc : ia.getInterfaces()) {
removeInterface(ifc);

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

@ -949,10 +949,9 @@ class CglibAopProxy implements AopProxy, Serializable { @@ -949,10 +949,9 @@ class CglibAopProxy implements AopProxy, Serializable {
if (this == other) {
return true;
}
if (!(other instanceof ProxyCallbackFilter)) {
if (!(other instanceof ProxyCallbackFilter otherCallbackFilter)) {
return false;
}
ProxyCallbackFilter otherCallbackFilter = (ProxyCallbackFilter) other;
AdvisedSupport otherAdvised = otherCallbackFilter.advised;
if (this.advised.isFrozen() != otherAdvised.isFrozen()) {
return false;

11
spring-aop/src/main/java/org/springframework/aop/framework/DefaultAdvisorChainFactory.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2021 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.
@ -60,9 +60,8 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ @@ -60,9 +60,8 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ
Boolean hasIntroductions = null;
for (Advisor advisor : advisors) {
if (advisor instanceof PointcutAdvisor) {
if (advisor instanceof PointcutAdvisor pointcutAdvisor) {
// Add it conditionally.
PointcutAdvisor pointcutAdvisor = (PointcutAdvisor) advisor;
if (config.isPreFiltered() || pointcutAdvisor.getPointcut().getClassFilter().matches(actualClass)) {
MethodMatcher mm = pointcutAdvisor.getPointcut().getMethodMatcher();
boolean match;
@ -90,8 +89,7 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ @@ -90,8 +89,7 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ
}
}
}
else if (advisor instanceof IntroductionAdvisor) {
IntroductionAdvisor ia = (IntroductionAdvisor) advisor;
else if (advisor instanceof IntroductionAdvisor ia) {
if (config.isPreFiltered() || ia.getClassFilter().matches(actualClass)) {
Interceptor[] interceptors = registry.getInterceptors(advisor);
interceptorList.addAll(Arrays.asList(interceptors));
@ -111,8 +109,7 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ @@ -111,8 +109,7 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ
*/
private static boolean hasMatchingIntroductions(Advisor[] advisors, Class<?> actualClass) {
for (Advisor advisor : advisors) {
if (advisor instanceof IntroductionAdvisor) {
IntroductionAdvisor ia = (IntroductionAdvisor) advisor;
if (advisor instanceof IntroductionAdvisor ia) {
if (ia.getClassFilter().matches(actualClass)) {
return true;
}

3
spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java

@ -479,8 +479,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport @@ -479,8 +479,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
Advisor[] advisors = getAdvisors();
List<Advisor> freshAdvisors = new ArrayList<>(advisors.length);
for (Advisor advisor : advisors) {
if (advisor instanceof PrototypePlaceholderAdvisor) {
PrototypePlaceholderAdvisor pa = (PrototypePlaceholderAdvisor) advisor;
if (advisor instanceof PrototypePlaceholderAdvisor pa) {
if (logger.isDebugEnabled()) {
logger.debug("Refreshing bean named '" + pa.getBeanName() + "'");
}

6
spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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,11 +165,9 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea @@ -165,11 +165,9 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
Object interceptorOrInterceptionAdvice =
this.interceptorsAndDynamicMethodMatchers.get(++this.currentInterceptorIndex);
if (interceptorOrInterceptionAdvice instanceof InterceptorAndDynamicMethodMatcher) {
if (interceptorOrInterceptionAdvice instanceof InterceptorAndDynamicMethodMatcher dm) {
// Evaluate dynamic method matcher here: static part will already have
// been evaluated and found to match.
InterceptorAndDynamicMethodMatcher dm =
(InterceptorAndDynamicMethodMatcher) interceptorOrInterceptionAdvice;
Class<?> targetClass = (this.targetClass != null ? this.targetClass : this.method.getDeclaringClass());
if (dm.methodMatcher.matches(this.method, targetClass, this.arguments)) {
return dm.interceptor.invoke(this);

3
spring-aop/src/main/java/org/springframework/aop/framework/adapter/DefaultAdvisorAdapterRegistry.java

@ -58,10 +58,9 @@ public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Se @@ -58,10 +58,9 @@ public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Se
if (adviceObject instanceof Advisor) {
return (Advisor) adviceObject;
}
if (!(adviceObject instanceof Advice)) {
if (!(adviceObject instanceof Advice advice)) {
throw new UnknownAdviceTypeException(adviceObject);
}
Advice advice = (Advice) adviceObject;
if (advice instanceof MethodInterceptor) {
// So well-known it doesn't even need an adapter.
return new DefaultPointcutAdvisor(advice);

9
spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisors.java

@ -68,10 +68,9 @@ public abstract class ExposeBeanNameAdvisors { @@ -68,10 +68,9 @@ public abstract class ExposeBeanNameAdvisors {
* @throws IllegalStateException if the bean name has not been exposed
*/
public static String getBeanName(MethodInvocation mi) throws IllegalStateException {
if (!(mi instanceof ProxyMethodInvocation)) {
if (!(mi instanceof ProxyMethodInvocation pmi)) {
throw new IllegalArgumentException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
}
ProxyMethodInvocation pmi = (ProxyMethodInvocation) mi;
String beanName = (String) pmi.getUserAttribute(BEAN_NAME_ATTRIBUTE);
if (beanName == null) {
throw new IllegalStateException("Cannot get bean name; not set on MethodInvocation: " + mi);
@ -113,10 +112,9 @@ public abstract class ExposeBeanNameAdvisors { @@ -113,10 +112,9 @@ public abstract class ExposeBeanNameAdvisors {
@Override
@Nullable
public Object invoke(MethodInvocation mi) throws Throwable {
if (!(mi instanceof ProxyMethodInvocation)) {
if (!(mi instanceof ProxyMethodInvocation pmi)) {
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
}
ProxyMethodInvocation pmi = (ProxyMethodInvocation) mi;
pmi.setUserAttribute(BEAN_NAME_ATTRIBUTE, this.beanName);
return mi.proceed();
}
@ -138,10 +136,9 @@ public abstract class ExposeBeanNameAdvisors { @@ -138,10 +136,9 @@ public abstract class ExposeBeanNameAdvisors {
@Override
@Nullable
public Object invoke(MethodInvocation mi) throws Throwable {
if (!(mi instanceof ProxyMethodInvocation)) {
if (!(mi instanceof ProxyMethodInvocation pmi)) {
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
}
ProxyMethodInvocation pmi = (ProxyMethodInvocation) mi;
pmi.setUserAttribute(BEAN_NAME_ATTRIBUTE, this.beanName);
return super.invoke(mi);
}

4
spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyFactoryBean.java

@ -85,11 +85,9 @@ public class ScopedProxyFactoryBean extends ProxyConfig @@ -85,11 +85,9 @@ public class ScopedProxyFactoryBean extends ProxyConfig
@Override
public void setBeanFactory(BeanFactory beanFactory) {
if (!(beanFactory instanceof ConfigurableBeanFactory)) {
if (!(beanFactory instanceof ConfigurableBeanFactory cbf)) {
throw new IllegalStateException("Not running in a ConfigurableBeanFactory: " + beanFactory);
}
ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory;
this.scopedTargetSource.setBeanFactory(beanFactory);
ProxyFactory pf = new ProxyFactory();

3
spring-aop/src/main/java/org/springframework/aop/support/AbstractPointcutAdvisor.java

@ -69,10 +69,9 @@ public abstract class AbstractPointcutAdvisor implements PointcutAdvisor, Ordere @@ -69,10 +69,9 @@ public abstract class AbstractPointcutAdvisor implements PointcutAdvisor, Ordere
if (this == other) {
return true;
}
if (!(other instanceof PointcutAdvisor)) {
if (!(other instanceof PointcutAdvisor otherAdvisor)) {
return false;
}
PointcutAdvisor otherAdvisor = (PointcutAdvisor) other;
return (ObjectUtils.nullSafeEquals(getAdvice(), otherAdvisor.getAdvice()) &&
ObjectUtils.nullSafeEquals(getPointcut(), otherAdvisor.getPointcut()));
}

3
spring-aop/src/main/java/org/springframework/aop/support/AbstractRegexpMethodPointcut.java

@ -200,10 +200,9 @@ public abstract class AbstractRegexpMethodPointcut extends StaticMethodMatcherPo @@ -200,10 +200,9 @@ public abstract class AbstractRegexpMethodPointcut extends StaticMethodMatcherPo
if (this == other) {
return true;
}
if (!(other instanceof AbstractRegexpMethodPointcut)) {
if (!(other instanceof AbstractRegexpMethodPointcut otherPointcut)) {
return false;
}
AbstractRegexpMethodPointcut otherPointcut = (AbstractRegexpMethodPointcut) other;
return (Arrays.equals(this.patterns, otherPointcut.patterns) &&
Arrays.equals(this.excludedPatterns, otherPointcut.excludedPatterns));
}

3
spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java

@ -284,8 +284,7 @@ public abstract class AopUtils { @@ -284,8 +284,7 @@ public abstract class AopUtils {
if (advisor instanceof IntroductionAdvisor) {
return ((IntroductionAdvisor) advisor).getClassFilter().matches(targetClass);
}
else if (advisor instanceof PointcutAdvisor) {
PointcutAdvisor pca = (PointcutAdvisor) advisor;
else if (advisor instanceof PointcutAdvisor pca) {
return canApply(pca.getPointcut(), targetClass, hasIntroductions);
}
else {

3
spring-aop/src/main/java/org/springframework/aop/support/ComposablePointcut.java

@ -188,10 +188,9 @@ public class ComposablePointcut implements Pointcut, Serializable { @@ -188,10 +188,9 @@ public class ComposablePointcut implements Pointcut, Serializable {
if (this == other) {
return true;
}
if (!(other instanceof ComposablePointcut)) {
if (!(other instanceof ComposablePointcut otherPointcut)) {
return false;
}
ComposablePointcut otherPointcut = (ComposablePointcut) other;
return (this.classFilter.equals(otherPointcut.classFilter) &&
this.methodMatcher.equals(otherPointcut.methodMatcher));
}

3
spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java

@ -128,10 +128,9 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher @@ -128,10 +128,9 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
if (this == other) {
return true;
}
if (!(other instanceof ControlFlowPointcut)) {
if (!(other instanceof ControlFlowPointcut that)) {
return false;
}
ControlFlowPointcut that = (ControlFlowPointcut) other;
return (this.clazz.equals(that.clazz)) && ObjectUtils.nullSafeEquals(this.methodName, that.methodName);
}

3
spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java

@ -155,10 +155,9 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil @@ -155,10 +155,9 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
if (this == other) {
return true;
}
if (!(other instanceof DefaultIntroductionAdvisor)) {
if (!(other instanceof DefaultIntroductionAdvisor otherAdvisor)) {
return false;
}
DefaultIntroductionAdvisor otherAdvisor = (DefaultIntroductionAdvisor) other;
return (this.advice.equals(otherAdvisor.advice) && this.interfaces.equals(otherAdvisor.interfaces));
}

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

@ -61,9 +61,9 @@ public class DelegatePerTargetObjectIntroductionInterceptor extends Introduction @@ -61,9 +61,9 @@ public class DelegatePerTargetObjectIntroductionInterceptor extends Introduction
*/
private final Map<Object, Object> delegateMap = new WeakHashMap<>();
private Class<?> defaultImplType;
private final Class<?> defaultImplType;
private Class<?> interfaceType;
private final Class<?> interfaceType;
public DelegatePerTargetObjectIntroductionInterceptor(Class<?> defaultImplType, Class<?> interfaceType) {

9
spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java

@ -146,10 +146,9 @@ public abstract class MethodMatchers { @@ -146,10 +146,9 @@ public abstract class MethodMatchers {
if (this == other) {
return true;
}
if (!(other instanceof UnionMethodMatcher)) {
if (!(other instanceof UnionMethodMatcher that)) {
return false;
}
UnionMethodMatcher that = (UnionMethodMatcher) other;
return (this.mm1.equals(that.mm1) && this.mm2.equals(that.mm2));
}
@ -223,8 +222,7 @@ public abstract class MethodMatchers { @@ -223,8 +222,7 @@ public abstract class MethodMatchers {
}
ClassFilter otherCf1 = ClassFilter.TRUE;
ClassFilter otherCf2 = ClassFilter.TRUE;
if (other instanceof ClassFilterAwareUnionMethodMatcher) {
ClassFilterAwareUnionMethodMatcher cfa = (ClassFilterAwareUnionMethodMatcher) other;
if (other instanceof ClassFilterAwareUnionMethodMatcher cfa) {
otherCf1 = cfa.cf1;
otherCf2 = cfa.cf2;
}
@ -312,10 +310,9 @@ public abstract class MethodMatchers { @@ -312,10 +310,9 @@ public abstract class MethodMatchers {
if (this == other) {
return true;
}
if (!(other instanceof IntersectionMethodMatcher)) {
if (!(other instanceof IntersectionMethodMatcher that)) {
return false;
}
IntersectionMethodMatcher that = (IntersectionMethodMatcher) other;
return (this.mm1.equals(that.mm1) && this.mm2.equals(that.mm2));
}

3
spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationClassFilter.java

@ -72,10 +72,9 @@ public class AnnotationClassFilter implements ClassFilter { @@ -72,10 +72,9 @@ public class AnnotationClassFilter implements ClassFilter {
if (this == other) {
return true;
}
if (!(other instanceof AnnotationClassFilter)) {
if (!(other instanceof AnnotationClassFilter otherCf)) {
return false;
}
AnnotationClassFilter otherCf = (AnnotationClassFilter) other;
return (this.annotationType.equals(otherCf.annotationType) && this.checkInherited == otherCf.checkInherited);
}

6
spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMatchingPointcut.java

@ -125,10 +125,9 @@ public class AnnotationMatchingPointcut implements Pointcut { @@ -125,10 +125,9 @@ public class AnnotationMatchingPointcut implements Pointcut {
if (this == other) {
return true;
}
if (!(other instanceof AnnotationMatchingPointcut)) {
if (!(other instanceof AnnotationMatchingPointcut otherPointcut)) {
return false;
}
AnnotationMatchingPointcut otherPointcut = (AnnotationMatchingPointcut) other;
return (this.classFilter.equals(otherPointcut.classFilter) &&
this.methodMatcher.equals(otherPointcut.methodMatcher));
}
@ -189,10 +188,9 @@ public class AnnotationMatchingPointcut implements Pointcut { @@ -189,10 +188,9 @@ public class AnnotationMatchingPointcut implements Pointcut {
if (this == obj) {
return true;
}
if (!(obj instanceof AnnotationCandidateClassFilter)) {
if (!(obj instanceof AnnotationCandidateClassFilter that)) {
return false;
}
AnnotationCandidateClassFilter that = (AnnotationCandidateClassFilter) obj;
return this.annotationType.equals(that.annotationType);
}

3
spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMethodMatcher.java

@ -92,10 +92,9 @@ public class AnnotationMethodMatcher extends StaticMethodMatcher { @@ -92,10 +92,9 @@ public class AnnotationMethodMatcher extends StaticMethodMatcher {
if (this == other) {
return true;
}
if (!(other instanceof AnnotationMethodMatcher)) {
if (!(other instanceof AnnotationMethodMatcher otherMm)) {
return false;
}
AnnotationMethodMatcher otherMm = (AnnotationMethodMatcher) other;
return (this.annotationType.equals(otherMm.annotationType) && this.checkInherited == otherMm.checkInherited);
}

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

@ -135,10 +135,9 @@ public final class EmptyTargetSource implements TargetSource, Serializable { @@ -135,10 +135,9 @@ public final class EmptyTargetSource implements TargetSource, Serializable {
if (this == other) {
return true;
}
if (!(other instanceof EmptyTargetSource)) {
if (!(other instanceof EmptyTargetSource otherTs)) {
return false;
}
EmptyTargetSource otherTs = (EmptyTargetSource) other;
return (ObjectUtils.nullSafeEquals(this.targetClass, otherTs.targetClass) && this.isStatic == otherTs.isStatic);
}

3
spring-aop/src/main/java/org/springframework/aop/target/SingletonTargetSource.java

@ -85,10 +85,9 @@ public class SingletonTargetSource implements TargetSource, Serializable { @@ -85,10 +85,9 @@ public class SingletonTargetSource implements TargetSource, Serializable {
if (this == other) {
return true;
}
if (!(other instanceof SingletonTargetSource)) {
if (!(other instanceof SingletonTargetSource otherTargetSource)) {
return false;
}
SingletonTargetSource otherTargetSource = (SingletonTargetSource) other;
return this.target.equals(otherTargetSource.target);
}

Loading…
Cancel
Save