diff --git a/spring-context/src/main/java/org/springframework/context/annotation/BeanMethod.java b/spring-context/src/main/java/org/springframework/context/annotation/BeanMethod.java index 6d3459fb08..abe73dacc6 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/BeanMethod.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/BeanMethod.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. @@ -39,6 +39,7 @@ final class BeanMethod extends ConfigurationMethod { super(metadata, configurationClass); } + @Override public void validate(ProblemReporter problemReporter) { if (getMetadata().isStatic()) { @@ -55,9 +56,9 @@ final class BeanMethod extends ConfigurationMethod { } @Override - public boolean equals(@Nullable Object obj) { - return ((this == obj) || ((obj instanceof BeanMethod) && - this.metadata.equals(((BeanMethod) obj).metadata))); + public boolean equals(@Nullable Object other) { + return (this == other || (other instanceof BeanMethod && + this.metadata.equals(((BeanMethod) other).metadata))); } @Override @@ -70,6 +71,7 @@ final class BeanMethod extends ConfigurationMethod { return "BeanMethod: " + this.metadata; } + private class NonOverridableMethodError extends Problem { NonOverridableMethodError() { diff --git a/spring-core/src/main/java/org/springframework/core/ParameterizedTypeReference.java b/spring-core/src/main/java/org/springframework/core/ParameterizedTypeReference.java index c10dd89aee..8e7bd2809f 100644 --- a/spring-core/src/main/java/org/springframework/core/ParameterizedTypeReference.java +++ b/spring-core/src/main/java/org/springframework/core/ParameterizedTypeReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 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. @@ -14,7 +14,6 @@ * limitations under the License. */ - package org.springframework.core; import java.lang.reflect.ParameterizedType; @@ -92,8 +91,7 @@ public abstract class ParameterizedTypeReference { * @since 4.3.12 */ public static ParameterizedTypeReference forType(Type type) { - return new ParameterizedTypeReference(type) { - }; + return new ParameterizedTypeReference(type) {}; } private static Class findParameterizedTypeReferenceSubclass(Class child) { diff --git a/spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java b/spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java index 5e7fce7c6c..9b666f91ed 100644 --- a/spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java +++ b/spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java @@ -168,31 +168,27 @@ final class ProfilesParser { return false; } - @Override - public int hashCode() { - return this.expressions.hashCode(); - } - @Override public boolean equals(Object obj) { if (this == obj) { return true; } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { + if (obj == null || getClass() != obj.getClass()) { return false; } ParsedProfiles that = (ParsedProfiles) obj; return this.expressions.equals(that.expressions); } + @Override + public int hashCode() { + return this.expressions.hashCode(); + } + @Override public String toString() { return StringUtils.collectionToDelimitedString(this.expressions, " or "); } - } } diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/SimpleAnnotationMetadataReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/SimpleAnnotationMetadataReadingVisitor.java index a951194ae7..700fcc5138 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/SimpleAnnotationMetadataReadingVisitor.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/SimpleAnnotationMetadataReadingVisitor.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. @@ -171,6 +171,7 @@ final class SimpleAnnotationMetadataReadingVisitor extends ClassVisitor { return (access & Opcodes.ACC_INTERFACE) != 0; } + /** * {@link MergedAnnotation} source. */ @@ -182,11 +183,6 @@ final class SimpleAnnotationMetadataReadingVisitor extends ClassVisitor { this.className = className; } - @Override - public int hashCode() { - return this.className.hashCode(); - } - @Override public boolean equals(@Nullable Object obj) { if (this == obj) { @@ -198,11 +194,15 @@ final class SimpleAnnotationMetadataReadingVisitor extends ClassVisitor { return this.className.equals(((Source) obj).className); } + @Override + public int hashCode() { + return this.className.hashCode(); + } + @Override public String toString() { return this.className; } - } } diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringFlushSynchronization.java b/spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringFlushSynchronization.java index 9457985188..cd64a15e80 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringFlushSynchronization.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringFlushSynchronization.java @@ -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. @@ -43,7 +43,6 @@ public class SpringFlushSynchronization implements TransactionSynchronization { SessionFactoryUtils.flush(this.session, false); } - @Override public boolean equals(@Nullable Object other) { return (this == other || (other instanceof SpringFlushSynchronization && diff --git a/spring-test/src/main/java/org/springframework/test/context/support/DynamicPropertiesContextCustomizer.java b/spring-test/src/main/java/org/springframework/test/context/support/DynamicPropertiesContextCustomizer.java index d7093a066a..b419f0b9e4 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/DynamicPropertiesContextCustomizer.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/DynamicPropertiesContextCustomizer.java @@ -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. @@ -46,7 +46,6 @@ class DynamicPropertiesContextCustomizer implements ContextCustomizer { private static final String PROPERTY_SOURCE_NAME = "Dynamic Test Properties"; - private final Set methods; @@ -65,9 +64,7 @@ class DynamicPropertiesContextCustomizer implements ContextCustomizer { } @Override - public void customizeContext(ConfigurableApplicationContext context, - MergedContextConfiguration mergedConfig) { - + public void customizeContext(ConfigurableApplicationContext context, MergedContextConfiguration mergedConfig) { MutablePropertySources sources = context.getEnvironment().getPropertySources(); sources.addFirst(new DynamicValuesPropertySource(PROPERTY_SOURCE_NAME, buildDynamicPropertiesMap())); } @@ -90,10 +87,6 @@ class DynamicPropertiesContextCustomizer implements ContextCustomizer { return this.methods; } - @Override - public int hashCode() { - return this.methods.hashCode(); - } @Override public boolean equals(Object obj) { @@ -106,4 +99,9 @@ class DynamicPropertiesContextCustomizer implements ContextCustomizer { return this.methods.equals(((DynamicPropertiesContextCustomizer) obj).methods); } + @Override + public int hashCode() { + return this.methods.hashCode(); + } + }