Class ConfigProviderImpl

java.lang.Object
dev.orne.config.impl.ConfigProviderImpl
All Implemented Interfaces:
ConfigProvider

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

    • ConfigProviderImpl

      public ConfigProviderImpl(Config defaultConfig)
      Creates a new instance.
      Parameters:
      defaultConfig - The default configuration
  • Method Details

    • registerConfig

      public void registerConfig(Config config)
      Registers a new configuration available for bean configuration.
      Parameters:
      config - The configuration to register
    • mapConfigType

      protected void mapConfigType(Class<?> type, Config config)
      Maps configuration type and all its interfaces to the instance passed as argument. If the type has super class different of Object repeats the mapping for it.
      Parameters:
      type - The type of configuration to scan
      config - The configuration instance
    • getDefaultConfig

      public Config getDefaultConfig()
      Returns the default Config instance.
      Specified by:
      getDefaultConfig in interface ConfigProvider
      Returns:
      The default Config instance
    • selectConfig

      public @Nullable Config selectConfig(@Nullable PreferredConfig preferences)
      Returns a suitable Config instance for the configuration preferences passed as argument.
      Specified by:
      selectConfig in interface ConfigProvider
      Parameters:
      preferences - The configuration preferences.
      Returns:
      The selected Config instance, or null if no one is suitable
    • getConfig

      public Optional<Config> getConfig(Class<? extends Config> type)
      Description copied from interface: ConfigProvider
      Returns the registered Config for the specified type, if any.
      Specified by:
      getConfig in interface ConfigProvider
      Parameters:
      type - The configuration type.
      Returns:
      The registered Config.