From ad0573a91e16fe0dc32babd865447df31e890e76 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 7 Jun 2022 11:52:40 +0200 Subject: [PATCH] Polish --- .../aot/BeanDefinitionPropertiesCodeGenerator.java | 12 +----------- .../aot/BeanFactoryInitializationAotProcessor.java | 12 ++++++------ .../factory/aot/BeanRegistrationAotContribution.java | 4 ++-- .../beans/factory/aot/BeanRegistrationCode.java | 4 ++-- .../factory/aot/BeanRegistrationCodeFragments.java | 4 +--- 5 files changed, 12 insertions(+), 24 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanDefinitionPropertiesCodeGenerator.java b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanDefinitionPropertiesCodeGenerator.java index ac25b4af6e..d186bafe1d 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanDefinitionPropertiesCodeGenerator.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanDefinitionPropertiesCodeGenerator.java @@ -21,7 +21,6 @@ import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.lang.reflect.Method; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -138,7 +137,7 @@ class BeanDefinitionPropertiesCodeGenerator { } private void addInitDestroyMethods(Builder builder, - AbstractBeanDefinition beanDefinition, String[] methodNames, String format) { + AbstractBeanDefinition beanDefinition, @Nullable String[] methodNames, String format) { if (!ObjectUtils.isEmpty(methodNames)) { Class beanType = ClassUtils @@ -237,15 +236,6 @@ class BeanDefinitionPropertiesCodeGenerator { return Collections.unmodifiableMap(writeMethods); } - @Nullable - private Method findWriteMethod(BeanInfo beanInfo, String propertyName) { - return Arrays.stream(beanInfo.getPropertyDescriptors()) - .filter(pd -> propertyName.equals(pd.getName())) - .map(java.beans.PropertyDescriptor::getWriteMethod) - .filter(Objects::nonNull).findFirst().orElse(null); - } - - private void addAttributes(CodeBlock.Builder builder, BeanDefinition beanDefinition) { String[] attributeNames = beanDefinition.attributeNames(); if (!ObjectUtils.isEmpty(attributeNames)) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanFactoryInitializationAotProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanFactoryInitializationAotProcessor.java index f48a53e145..2b5bd19823 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanFactoryInitializationAotProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanFactoryInitializationAotProcessor.java @@ -28,6 +28,7 @@ import org.springframework.lang.Nullable; * {@link org.springframework.beans.factory.aot.BeanRegistrationExcludeFilter}. * * @author Phillip Webb + * @author Stephane Nicoll * @since 6.0 * @see BeanFactoryInitializationAotContribution */ @@ -39,15 +40,14 @@ public interface BeanFactoryInitializationAotProcessor { * ahead-of-time and return a contribution or {@code null}. *

* Processors are free to use any techniques they like to analyze the given - * instance. Most typically use reflection to find fields or methods to use - * in the contribution. Contributions typically generate source code or + * bean factory. Most typically use reflection to find fields or methods to + * use in the contribution. Contributions typically generate source code or * resource files that can be used when the AOT optimized application runs. *

- * If the given instance isn't relevant to the processor, it should return a - * {@code null} contribution. + * If the given bean factory does not contain anything that is relevant to + * the processor, it should return a {@code null} contribution. * @param beanFactory the bean factory to process - * @return a {@link BeanFactoryInitializationAotContribution} or - * {@code null} + * @return a {@link BeanFactoryInitializationAotContribution} or {@code null} */ @Nullable BeanFactoryInitializationAotContribution processAheadOfTime( diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationAotContribution.java b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationAotContribution.java index 6b6bdee052..d3352d96d6 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationAotContribution.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationAotContribution.java @@ -48,7 +48,7 @@ public interface BeanRegistrationAotContribution { /** * Apply this contribution to the given {@link BeanRegistrationCode}. - * @param generationContext the active generation context + * @param generationContext the generation context * @param beanRegistrationCode the generated registration */ void applyTo(GenerationContext generationContext, @@ -61,7 +61,7 @@ public interface BeanRegistrationAotContribution { * @param beanRegistrationCodeFragmentsCustomizer the * {@link BeanRegistrationCodeFragments} customizer * @return a new {@link BeanRegistrationAotContribution} instance - * @see #customizeBeanRegistrationCodeFragments(BeanRegistrationCodeFragments) + * @see #customizeBeanRegistrationCodeFragments(GenerationContext, BeanRegistrationCodeFragments) */ static BeanRegistrationAotContribution ofBeanRegistrationCodeFragmentsCustomizer( UnaryOperator beanRegistrationCodeFragmentsCustomizer) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationCode.java b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationCode.java index fe8909b1eb..6bcd48646f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationCode.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationCode.java @@ -20,6 +20,7 @@ import org.springframework.aot.generate.MethodGenerator; import org.springframework.aot.generate.MethodReference; import org.springframework.beans.factory.support.InstanceSupplier; import org.springframework.javapoet.ClassName; +import org.springframework.util.function.ThrowingBiFunction; /** * Interface that can be used to configure the code that will be generated to @@ -28,7 +29,6 @@ import org.springframework.javapoet.ClassName; * @author Phillip Webb * @since 6.0 * @see BeanRegistrationCodeFragments - * @see BeanRegistrationCodeFragmentsCustomizer */ public interface BeanRegistrationCode { @@ -50,7 +50,7 @@ public interface BeanRegistrationCode { * @param methodReference a reference to the post-process method to call. * The referenced method must have a functional signature compatible with * {@link InstanceSupplier#andThen}. - * @see InstanceSupplier#andThen(org.springframework.util.function.ThrowableBiFunction) + * @see InstanceSupplier#andThen(ThrowingBiFunction) */ void addInstancePostProcessor(MethodReference methodReference); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationCodeFragments.java b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationCodeFragments.java index acc2c0b935..b409d4d71d 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationCodeFragments.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationCodeFragments.java @@ -35,8 +35,6 @@ import org.springframework.util.Assert; * * @author Phillip Webb * @since 6.0 - * @see BeanRegistrationCodeFragmentsWrapper - * @see BeanRegistrationCodeFragmentsCustomizer */ public abstract class BeanRegistrationCodeFragments { @@ -55,7 +53,7 @@ public abstract class BeanRegistrationCodeFragments { protected BeanRegistrationCodeFragments(BeanRegistrationCodeFragments codeFragments) { - Assert.notNull(codeFragments, "'codeFragments' must not be null"); + Assert.notNull(codeFragments, "CodeFragments must not be null"); this.codeFragments = codeFragments; }