Consistent equals implementations in AOP support classes

This commit is contained in:
Juergen Hoeller
2023-06-08 17:36:39 +02:00
parent 6931106c5e
commit c16f582ed8
12 changed files with 52 additions and 119 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -196,14 +196,9 @@ public abstract class AbstractRegexpMethodPointcut extends StaticMethodMatcherPo
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AbstractRegexpMethodPointcut otherPointcut)) {
return false;
}
return (Arrays.equals(this.patterns, otherPointcut.patterns) &&
Arrays.equals(this.excludedPatterns, otherPointcut.excludedPatterns));
return (this == other || (other instanceof AbstractRegexpMethodPointcut otherPointcut &&
Arrays.equals(this.patterns, otherPointcut.patterns) &&
Arrays.equals(this.excludedPatterns, otherPointcut.excludedPatterns)));
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -187,14 +187,9 @@ public class ComposablePointcut implements Pointcut, Serializable {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ComposablePointcut otherPointcut)) {
return false;
}
return (this.classFilter.equals(otherPointcut.classFilter) &&
this.methodMatcher.equals(otherPointcut.methodMatcher));
return (this == other || (other instanceof ComposablePointcut otherPointcut &&
this.classFilter.equals(otherPointcut.classFilter) &&
this.methodMatcher.equals(otherPointcut.methodMatcher)));
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -125,13 +125,9 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ControlFlowPointcut that)) {
return false;
}
return (this.clazz.equals(that.clazz)) && ObjectUtils.nullSafeEquals(this.methodName, that.methodName);
return (this == other || (other instanceof ControlFlowPointcut that &&
this.clazz.equals(that.clazz)) &&
ObjectUtils.nullSafeEquals(this.methodName, that.methodName));
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -143,13 +143,8 @@ public abstract class MethodMatchers {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof UnionMethodMatcher that)) {
return false;
}
return (this.mm1.equals(that.mm1) && this.mm2.equals(that.mm2));
return (this == other || (other instanceof UnionMethodMatcher that &&
this.mm1.equals(that.mm1) && this.mm2.equals(that.mm2)));
}
@Override
@@ -307,13 +302,8 @@ public abstract class MethodMatchers {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof IntersectionMethodMatcher that)) {
return false;
}
return (this.mm1.equals(that.mm1) && this.mm2.equals(that.mm2));
return (this == other || (other instanceof IntersectionMethodMatcher that &&
this.mm1.equals(that.mm1) && this.mm2.equals(that.mm2)));
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -68,13 +68,9 @@ public class AnnotationClassFilter implements ClassFilter {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AnnotationClassFilter otherCf)) {
return false;
}
return (this.annotationType.equals(otherCf.annotationType) && this.checkInherited == otherCf.checkInherited);
return (this == other || (other instanceof AnnotationClassFilter otherCf &&
this.annotationType.equals(otherCf.annotationType) &&
this.checkInherited == otherCf.checkInherited));
}
@Override

View File

@@ -121,14 +121,9 @@ public class AnnotationMatchingPointcut implements Pointcut {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AnnotationMatchingPointcut otherPointcut)) {
return false;
}
return (this.classFilter.equals(otherPointcut.classFilter) &&
this.methodMatcher.equals(otherPointcut.methodMatcher));
return (this == other || (other instanceof AnnotationMatchingPointcut otherPointcut &&
this.classFilter.equals(otherPointcut.classFilter) &&
this.methodMatcher.equals(otherPointcut.methodMatcher)));
}
@Override
@@ -183,14 +178,9 @@ public class AnnotationMatchingPointcut implements Pointcut {
}
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof AnnotationCandidateClassFilter that)) {
return false;
}
return this.annotationType.equals(that.annotationType);
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof AnnotationCandidateClassFilter that &&
this.annotationType.equals(that.annotationType)));
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,10 +27,9 @@ import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
* Simple {@link org.springframework.aop.MethodMatcher MethodMatcher} that looks
* for a specific annotation being present on a method (checking both the method
* on the invoked interface, if any, and the corresponding method on the target
* class).
* Simple {@link org.springframework.aop.MethodMatcher MethodMatcher} that looks for
* a specific annotation being present on a method (checking both the method on the
* invoked interface, if any, and the corresponding method on the target class).
*
* @author Juergen Hoeller
* @author Sam Brannen
@@ -90,13 +89,9 @@ public class AnnotationMethodMatcher extends StaticMethodMatcher {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AnnotationMethodMatcher otherMm)) {
return false;
}
return (this.annotationType.equals(otherMm.annotationType) && this.checkInherited == otherMm.checkInherited);
return (this == other || (other instanceof AnnotationMethodMatcher otherMm &&
this.annotationType.equals(otherMm.annotationType) &&
this.checkInherited == otherMm.checkInherited));
}
@Override