From 8413002bcb6bc645f6d9e3b705ac82e051606389 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 7 Jun 2022 20:02:06 +0200 Subject: [PATCH] Polish See gh-31247 --- .../ConfigurationPropertiesBeanRegistrar.java | 3 +-- ...rationPropertiesBeanRegistrationAotProcessor.java | 6 +++--- ...ndingValueSupplier.java => ConstructorBound.java} | 12 ++++++------ 3 files changed, 10 insertions(+), 11 deletions(-) rename spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/{ConstructorBindingValueSupplier.java => ConstructorBound.java} (80%) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanRegistrar.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanRegistrar.java index 73fe793ff3..182d611a40 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanRegistrar.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanRegistrar.java @@ -93,8 +93,7 @@ final class ConfigurationPropertiesBeanRegistrar { RootBeanDefinition definition = new RootBeanDefinition(type); definition.setAttribute(BindMethod.class.getName(), bindMethod); if (bindMethod == BindMethod.VALUE_OBJECT) { - definition.setInstanceSupplier( - () -> ConstructorBindingValueSupplier.createValueObject(this.beanFactory, beanName, type)); + definition.setInstanceSupplier(() -> ConstructorBound.from(this.beanFactory, beanName, type)); } return definition; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanRegistrationAotProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanRegistrationAotProcessor.java index 32710fd922..00c66cfc8e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanRegistrationAotProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanRegistrationAotProcessor.java @@ -37,7 +37,7 @@ import org.springframework.javapoet.CodeBlock; * {@link BeanRegistrationAotProcessor} for immutable configuration properties. * * @author Stephane Nicoll - * @see ConstructorBindingValueSupplier + * @see ConstructorBound */ class ConfigurationPropertiesBeanRegistrationAotProcessor implements BeanRegistrationAotProcessor { @@ -83,8 +83,8 @@ class ConfigurationPropertiesBeanRegistrationAotProcessor implements BeanRegistr builder.addStatement("$T beanFactory = registeredBean.getBeanFactory()", BeanFactory.class); builder.addStatement("$T beanName = registeredBean.getBeanName()", String.class); builder.addStatement("$T beanClass = registeredBean.getBeanClass()", Class.class); - builder.addStatement("return ($T) $T.createValueObject(beanFactory, beanName, beanClass)", - beanClass, ConstructorBindingValueSupplier.class); + builder.addStatement("return ($T) $T.from(beanFactory, beanName, beanClass)", beanClass, + ConstructorBound.class); }); return CodeBlock.of("$T.of($T::$L)", InstanceSupplier.class, beanRegistrationCode.getClassName(), method.getName()); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConstructorBindingValueSupplier.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConstructorBound.java similarity index 80% rename from spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConstructorBindingValueSupplier.java rename to spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConstructorBound.java index 73a0236e42..9bf78961d9 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConstructorBindingValueSupplier.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConstructorBound.java @@ -23,20 +23,20 @@ import org.springframework.beans.factory.BeanFactory; * injection. * * @author Stephane Nicoll - * @since 6.0 + * @since 3.0 * @see ConstructorBinding */ -public abstract class ConstructorBindingValueSupplier { +public abstract class ConstructorBound { /** - * Return an immutable {@link ConfigurationProperties} instance for the specified - * {@code beanType}. + * Create an immutable {@link ConfigurationProperties} instance for the specified + * {@code beanName} and {@code beanType} using the specified {@link BeanFactory}. * @param beanFactory the bean factory to use * @param beanName the name of the bean * @param beanType the type of the bean - * @return a new instance + * @return an instance from the specified bean */ - public static Object createValueObject(BeanFactory beanFactory, String beanName, Class beanType) { + public static Object from(BeanFactory beanFactory, String beanName, Class beanType) { ConfigurationPropertiesBean bean = ConfigurationPropertiesBean.forValueObject(beanType, beanName); ConfigurationPropertiesBinder binder = ConfigurationPropertiesBinder.get(beanFactory); try {