Interface ConfigBuilder
-
@ProviderType public interface ConfigBuilder
A builder for manually creating a configuration instance.- Author:
- Romain Manni-Bucau, Mark Struberg, Emily Jiang
- See Also:
ConfigProviderResolver.getBuilder()
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ConfigBuilder
addDefaultSources()
Add the default configuration sources to the configuration being built.ConfigBuilder
addDiscoveredConverters()
Add all configuration converters which can be discovered from this configuration builder's class loader.ConfigBuilder
addDiscoveredSources()
Add all configuration sources which can be discovered from this configuration builder's class loader.Config
build()
Build a newConfig
instance based on this builder instance.ConfigBuilder
forClassLoader(ClassLoader loader)
Specify the class loader for which this configuration is being built.<T> ConfigBuilder
withConverter(Class<T> type, int priority, Converter<T> converter)
Add the specifiedConverter
instance for the given type to the configuration being built.ConfigBuilder
withConverters(Converter<?>... converters)
Add the specifiedConverter
instances to the configuration being built.ConfigBuilder
withSources(ConfigSource... sources)
Add the specifiedConfigSource
instances to the configuration being built.
-
-
-
Method Detail
-
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 specifiedConfigSource
instances to the configuration being built.- Parameters:
sources
- the configuration sources- Returns:
- this configuration builder instance
-
withConverters
ConfigBuilder withConverters(Converter<?>... converters)
Add the specifiedConverter
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 specifiedConverter
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 convertpriority
- the priority of the converterconverter
- the converter (can not benull
)- Returns:
- this configuration builder instance
-
-