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(ConfigProvider configProvider) Creates a new instance.ConfigurerImpl(ConfigProvider configProvider, org.apache.commons.beanutils.ConvertUtilsBean converter) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidconfigure(Configurable bean) Configures the bean passed as argument.protected voidconfigureNestedBeans(Configurable bean, Config config) Configures the nested beans of the bean passed as argument with the selected configuration.protected voidconfigureProperties(Configurable bean, Config config) Configures the properties of the bean passed as argument with the selected configuration.protected voidconfigureProperty(Object bean, Field field, 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 org.apache.commons.beanutils.ConvertUtilsBeanCreates a new value converter configured with the default settings.protected Collection<Field>scanConfigurableProperties(Class<?> targetClass) Scans the fields annotated withConfigurablePropertyin the bean class passed as argument.protected Collection<Configurable>scanNestedComponents(Object bean) Scans the fields of the bean passed as argument for instances ofConfigurablenot configured.protected voidsetPropertyValue(Object bean, Field field, @Nullable 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(ConfigProvider configProvider, org.apache.commons.beanutils.ConvertUtilsBean converter) Creates a new instance.- Parameters:
configProvider- The configuration providerconverter- The value converter.
-
-
Method Details
-
defaultConverter
public static 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
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
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
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
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
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
-