Interface ConfigBuilder


@ProviderType public interface ConfigBuilder
A builder for manually creating a configuration instance.
See Also:
  • Method Details

    • addDefaultSources

      ConfigBuilder addDefaultSources()
      Add the default configuration sources to the configuration being built.
      Returns:
      this configuration builder instance
    • addDiscoveredSources

      ConfigBuilder addDiscoveredSources()
      Add all configuration sources which can be discovered from this configuration builder's class loader.
      Returns:
      this configuration builder instance
    • addDiscoveredConverters

      ConfigBuilder addDiscoveredConverters()
      Add all configuration converters which can be discovered from this configuration builder's class loader.
      Returns:
      this configuration builder instance
    • forClassLoader

      ConfigBuilder forClassLoader(ClassLoader loader)
      Specify the class loader for which this configuration is being built.
      Parameters:
      loader - the class loader
      Returns:
      this configuration builder instance
    • withSources

      ConfigBuilder withSources(ConfigSource... sources)
      Add the specified ConfigSource instances to the configuration being built.
      Parameters:
      sources - the configuration sources
      Returns:
      this configuration builder instance
    • withConverters

      ConfigBuilder withConverters(Converter<?>... converters)
      Add the specified Converter instances to the configuration being built.

      The implementation may use reflection to determine the target type of the converter. If the type cannot be determined reflectively, this method may fail with a runtime exception.

      When using lambda expressions for custom converters you should use the withConverter(Class, int, Converter) method and pass the target type explicitly, since lambda expressions generally do not offer enough type information to the reflection API in order to determine the target converter type.

      The added converters will be given a priority of 100.

      Parameters:
      converters - the converters to add
      Returns:
      this configuration builder instance
    • withConverter

      <T> ConfigBuilder withConverter(Class<T> type, int priority, Converter<T> converter)
      Add the specified Converter instance for the given type to the configuration being built.

      This method does not rely on reflection to determine the target type of the converter; therefore, lambda expressions may be used for the converter instance.

      The priority value of custom converters defaults to 100 if not specified.

      Type Parameters:
      T - the type to convert
      Parameters:
      type - the class of the type to convert
      priority - the priority of the converter
      converter - the converter (can not be null)
      Returns:
      this configuration builder instance
    • build

      Config build()
      Build a new Config instance based on this builder instance.
      Returns:
      the new configuration object