Polish
See gh-31247
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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 {
|
||||
Reference in New Issue
Block a user