Consistent equals/hashCode style (and related polishing)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user