public interface ConfigBuilder
ConfigProviderResolver.getBuilder()
Modifier and Type | Method and 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 new
Config instance based on this builder instance. |
ConfigBuilder |
forClassLoader(java.lang.ClassLoader loader)
Specify the class loader for which this configuration is being built.
|
<T> ConfigBuilder |
withConverter(java.lang.Class<T> type,
int priority,
Converter<T> converter)
Add the specified
Converter instance for the given type to the configuration being built. |
ConfigBuilder |
withConverters(Converter<?>... converters)
Add the specified
Converter instances to the configuration being built. |
ConfigBuilder |
withSources(ConfigSource... sources)
Add the specified
ConfigSource instances to the configuration being built. |
ConfigBuilder addDefaultSources()
ConfigBuilder addDiscoveredSources()
ConfigBuilder addDiscoveredConverters()
ConfigBuilder forClassLoader(java.lang.ClassLoader loader)
loader
- the class loaderConfigBuilder withSources(ConfigSource... sources)
ConfigSource
instances to the configuration being built.sources
- the configuration sourcesConfigBuilder withConverters(Converter<?>... converters)
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
.
converters
- the converters to add<T> ConfigBuilder withConverter(java.lang.Class<T> type, int priority, Converter<T> converter)
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.
T
- the type to converttype
- the class of the type to convertpriority
- the priority of the converterconverter
- the converter (can not be null
)