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(@NotNull @NotNull Config defaultConfig)
      Creates a new instance.
      Parameters:
      defaultConfig - The default configuration
  • Method Details

    • registerConfig

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

      protected void mapConfigType(@NotNull @NotNull Class<?> type, @NotNull @NotNull 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

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

      public Config selectConfig(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

      @NotNull public @NotNull Optional<Config> getConfig(@NotNull @NotNull 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.