java.lang.Object
dev.orne.config.impl.ConfigurerImpl
- All Implemented Interfaces:
Configurer
Default implementation of
Configurer.- Since:
- 0.1
- Version:
- 1.0, 2019-07, 2.0, 2025-07
- Author:
- (w) Iker Hernaez
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConfigurerImpl(@NotNull ConfigProvider configProvider) Creates a new instance.ConfigurerImpl(@NotNull ConfigProvider configProvider, @NotNull org.apache.commons.beanutils.ConvertUtilsBean converter) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidconfigure(@NotNull Configurable bean) Configures the bean passed as argument.protected voidconfigureNestedBeans(@NotNull Configurable bean, @NotNull Config config) Configures the nested beans of the bean passed as argument with the selected configuration.protected voidconfigureProperties(@NotNull Configurable bean, @NotNull Config config) Configures the properties of the bean passed as argument with the selected configuration.protected voidconfigureProperty(@NotNull Object bean, @NotNull Field field, @NotNull Config config) Configures the requested property in the bean with the provided configuration.protected <T> TconvertValue(String value, Class<T> type) Converts the configuration property value to the specified target type.static @NotNull org.apache.commons.beanutils.ConvertUtilsBeanCreates a new value converter configured with the default settings.protected @NotNull Collection<Field>scanConfigurableProperties(Class<?> targetClass) Scans the fields annotated withConfigurablePropertyin the bean class passed as argument.protected @NotNull Collection<Configurable>scanNestedComponents(@NotNull Object bean) Scans the fields of the bean passed as argument for instances ofConfigurablenot configured.protected voidsetPropertyValue(@NotNull Object bean, @NotNull Field field, Object value) Sets the specified property of the specified bean with the specified value.
-
Constructor Details
-
ConfigurerImpl
Creates a new instance.- Parameters:
configProvider- The configuration provider
-
ConfigurerImpl
public ConfigurerImpl(@NotNull @NotNull ConfigProvider configProvider, @NotNull @NotNull org.apache.commons.beanutils.ConvertUtilsBean converter) Creates a new instance.- Parameters:
configProvider- The configuration providerconverter- The value converter.
-
-
Method Details
-
defaultConverter
@NotNull public static @NotNull org.apache.commons.beanutils.ConvertUtilsBean defaultConverter()Creates a new value converter configured with the default settings.
This converter is configured to:
- Return
nullfornullvalues. - Return
nullfor values of incompatible types. - Return empty arrays for
nullvalues. - Return empty collections for
nullvalues.
- Returns:
- A new value converter configured with the default settings
- Return
-
configure
Configures the bean passed as argument.- Specified by:
configurein interfaceConfigurer- Parameters:
bean- The bean to configure.
-
configureProperties
protected void configureProperties(@NotNull @NotNull Configurable bean, @NotNull @NotNull Config config) Configures the properties of the bean passed as argument with the selected configuration.- Parameters:
bean- The bean which properties configureconfig- The configuration to use
-
scanConfigurableProperties
Scans the fields annotated withConfigurablePropertyin the bean class passed as argument.- Parameters:
targetClass- The bean class to scan for configurable fields- Returns:
- The configurable fields detected
-
configureProperty
protected void configureProperty(@NotNull @NotNull Object bean, @NotNull @NotNull Field field, @NotNull @NotNull Config config) Configures the requested property in the bean with the provided configuration.- Parameters:
bean- The instance of the beanfield- The property of the bean to configureconfig- The configuration to use
-
convertValue
Converts the configuration property value to the specified target type.- Type Parameters:
T- The target type.- Parameters:
value- The configuration property value.type- The target type.- Returns:
- The converted configuration value. throws ConfigException If an error occurs converting the value.
-
setPropertyValue
protected void setPropertyValue(@NotNull @NotNull Object bean, @NotNull @NotNull Field field, Object value) Sets the specified property of the specified bean with the specified value.- Parameters:
bean- The instance of the beanfield- The property of the bean to setvalue- The value to set
-
configureNestedBeans
protected void configureNestedBeans(@NotNull @NotNull Configurable bean, @NotNull @NotNull Config config) Configures the nested beans of the bean passed as argument with the selected configuration.- Parameters:
bean- The bean which nested beans configureconfig- The configuration to use
-
scanNestedComponents
@NotNull protected @NotNull Collection<Configurable> scanNestedComponents(@NotNull @NotNull Object bean) Scans the fields of the bean passed as argument for instances ofConfigurablenot configured.- Parameters:
bean- The bean to scan for unconfigured nested beans- Returns:
- The nested beans detected
-