Class ConfigurerImpl

java.lang.Object
dev.orne.config.impl.ConfigurerImpl
All Implemented Interfaces:
Configurer

@API(status=INTERNAL, since="1.0") public class ConfigurerImpl extends Object implements Configurer
Default implementation of Configurer.
Since:
0.1
Version:
1.0, 2019-07, 2.0, 2025-07
Author:
(w) Iker Hernaez
See Also:
  • Constructor Details

    • ConfigurerImpl

      public ConfigurerImpl(@NotNull @NotNull ConfigProvider configProvider)
      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 provider
      converter - 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 null for null values.
      • Return null for values of incompatible types.
      • Return empty arrays for null values.
      • Return empty collections for null values.
      Returns:
      A new value converter configured with the default settings
    • configure

      public void configure(@NotNull @NotNull Configurable bean)
      Configures the bean passed as argument.
      Specified by:
      configure in interface Configurer
      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 configure
      config - The configuration to use
    • scanConfigurableProperties

      @NotNull protected @NotNull Collection<Field> scanConfigurableProperties(Class<?> targetClass)
      Scans the fields annotated with ConfigurableProperty in 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 bean
      field - The property of the bean to configure
      config - The configuration to use
    • convertValue

      protected <T> T convertValue(String value, Class<T> type)
      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 bean
      field - The property of the bean to set
      value - 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 configure
      config - 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 of Configurable not configured.
      Parameters:
      bean - The bean to scan for unconfigured nested beans
      Returns:
      The nested beans detected