diff --git a/spring-aop/src/main/java/org/springframework/aop/support/AbstractRegexpMethodPointcut.java b/spring-aop/src/main/java/org/springframework/aop/support/AbstractRegexpMethodPointcut.java index 44f5766901..30fead6732 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/AbstractRegexpMethodPointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/AbstractRegexpMethodPointcut.java @@ -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 diff --git a/spring-aop/src/main/java/org/springframework/aop/support/ComposablePointcut.java b/spring-aop/src/main/java/org/springframework/aop/support/ComposablePointcut.java index 1ac7fd2117..432635510c 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/ComposablePointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/ComposablePointcut.java @@ -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 diff --git a/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java b/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java index 788eae69a5..67eeecea0e 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java @@ -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 diff --git a/spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java b/spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java index 19bf5adbb0..22e8b44d2d 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java @@ -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 diff --git a/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationClassFilter.java b/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationClassFilter.java index 997bcb9509..9b234633ad 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationClassFilter.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationClassFilter.java @@ -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 diff --git a/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMatchingPointcut.java b/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMatchingPointcut.java index 4dacd14936..421063c67f 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMatchingPointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMatchingPointcut.java @@ -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 diff --git a/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMethodMatcher.java b/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMethodMatcher.java index af5dfa4cdc..520519ff72 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMethodMatcher.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMethodMatcher.java @@ -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 diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/AnnotationCacheOperationSource.java b/spring-context/src/main/java/org/springframework/cache/annotation/AnnotationCacheOperationSource.java index 230a36d187..acc7242121 100644 --- a/spring-context/src/main/java/org/springframework/cache/annotation/AnnotationCacheOperationSource.java +++ b/spring-context/src/main/java/org/springframework/cache/annotation/AnnotationCacheOperationSource.java @@ -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,14 +165,9 @@ public class AnnotationCacheOperationSource extends AbstractFallbackCacheOperati @Override public boolean equals(@Nullable Object other) { - if (this == other) { - return true; - } - if (!(other instanceof AnnotationCacheOperationSource otherCos)) { - return false; - } - return (this.annotationParsers.equals(otherCos.annotationParsers) && - this.publicMethodsOnly == otherCos.publicMethodsOnly); + return (this == other || (other instanceof AnnotationCacheOperationSource otherCos && + this.annotationParsers.equals(otherCos.annotationParsers) && + this.publicMethodsOnly == otherCos.publicMethodsOnly)); } @Override diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/NameMatchCacheOperationSource.java b/spring-context/src/main/java/org/springframework/cache/interceptor/NameMatchCacheOperationSource.java index d916e3f89c..a06cb8cf4b 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/NameMatchCacheOperationSource.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/NameMatchCacheOperationSource.java @@ -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,13 +111,8 @@ public class NameMatchCacheOperationSource implements CacheOperationSource, Seri @Override public boolean equals(@Nullable Object other) { - if (this == other) { - return true; - } - if (!(other instanceof NameMatchCacheOperationSource otherTas)) { - return false; - } - return ObjectUtils.nullSafeEquals(this.nameMap, otherTas.nameMap); + return (this == other || (other instanceof NameMatchCacheOperationSource otherCos && + ObjectUtils.nullSafeEquals(this.nameMap, otherCos.nameMap))); } @Override @@ -129,4 +124,5 @@ public class NameMatchCacheOperationSource implements CacheOperationSource, Seri public String toString() { return getClass().getName() + ": " + this.nameMap; } + } diff --git a/spring-tx/src/main/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSource.java index 5d4e2e9395..4b6b81b708 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSource.java +++ b/spring-tx/src/main/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSource.java @@ -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. @@ -191,14 +191,9 @@ public class AnnotationTransactionAttributeSource extends AbstractFallbackTransa @Override public boolean equals(@Nullable Object other) { - if (this == other) { - return true; - } - if (!(other instanceof AnnotationTransactionAttributeSource otherTas)) { - return false; - } - return (this.annotationParsers.equals(otherTas.annotationParsers) && - this.publicMethodsOnly == otherTas.publicMethodsOnly); + return (this == other || (other instanceof AnnotationTransactionAttributeSource otherTas && + this.annotationParsers.equals(otherTas.annotationParsers) && + this.publicMethodsOnly == otherTas.publicMethodsOnly)); } @Override diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/MethodMapTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/MethodMapTransactionAttributeSource.java index e328a88a2e..5b90510878 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/MethodMapTransactionAttributeSource.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/MethodMapTransactionAttributeSource.java @@ -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. @@ -239,13 +239,8 @@ public class MethodMapTransactionAttributeSource @Override public boolean equals(@Nullable Object other) { - if (this == other) { - return true; - } - if (!(other instanceof MethodMapTransactionAttributeSource otherTas)) { - return false; - } - return ObjectUtils.nullSafeEquals(this.methodMap, otherTas.methodMap); + return (this == other || (other instanceof MethodMapTransactionAttributeSource otherTas && + ObjectUtils.nullSafeEquals(this.methodMap, otherTas.methodMap))); } @Override diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java index a0f4e15bf4..0b2cc33f11 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -164,13 +164,8 @@ public class NameMatchTransactionAttributeSource @Override public boolean equals(@Nullable Object other) { - if (this == other) { - return true; - } - if (!(other instanceof NameMatchTransactionAttributeSource otherTas)) { - return false; - } - return ObjectUtils.nullSafeEquals(this.nameMap, otherTas.nameMap); + return (this == other || (other instanceof NameMatchTransactionAttributeSource otherTas && + ObjectUtils.nullSafeEquals(this.nameMap, otherTas.nameMap))); } @Override