Interface ConfigBuilder


@ProviderType public interface ConfigBuilder
Builder for manually creating an instance of a Config.
See Also:
  • Method Details

    • addDefaultSources

      ConfigBuilder addDefaultSources()
      Add the default config sources appearing on the builder's classpath including:
      1. System properties
      2. Environment properties
      3. /META-INF/microprofile-config.properties
      Returns:
      the ConfigBuilder with the default config sources
    • addDiscoveredSources

      ConfigBuilder addDiscoveredSources()
      Add the config sources appearing to be loaded via service loader pattern
      Returns:
      the ConfigBuilder with the autodiscovered config sources
    • addDiscoveredConverters

      ConfigBuilder addDiscoveredConverters()
      Add the converters to be loaded via service loader pattern
      Returns:
      the ConfigBuilder with the autodiscovered converters
    • forClassLoader

      ConfigBuilder forClassLoader(ClassLoader loader)
      Return the ConfigBuilder for a given classloader
      Parameters:
      loader - the specified classloader
      Returns:
      the ConfigureBuilder for the given classloader
    • withSources

      ConfigBuilder withSources(ConfigSource... sources)
      Add the specified ConfigSource.
      Parameters:
      sources - the config sources
      Returns:
      the ConfigBuilder with the configured sources
    • withConverters

      ConfigBuilder withConverters(Converter<?>... converters)
      Add the specified Converter. This method uses reflection to determine what type the converter is for. When using lambda expressions for custom converters you should use withConverter(Class, int, Converter) and pass the target type explicitly as lambda expressions do not offer enough type information to the reflection API.
      Parameters:
      converters - the converters
      Returns:
      the ConfigBuilder with the added converters
    • withConverter

      <T> ConfigBuilder withConverter(Class<T> type, int priority, Converter<T> converter)
      Add the specified Converter for the given type. This method does not rely on reflection to determine what type the converter is for therefore also lambda expressions can be used.
      Type Parameters:
      T - the type to convert
      Parameters:
      type - the Class of type to convert
      priority - the priority of the converter (custom converters have a default priority of 100).
      converter - the converter (can not be null)
      Returns:
      the ConfigBuilder with the added converters
    • build

      Config build()
      Build the Config object.
      Returns:
      the Config object