Interface ConfigBuilder
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionAdd the default configuration sources to the configuration being built.Add all configuration converters which can be discovered from this configuration builder's class loader.Add all configuration sources which can be discovered from this configuration builder's class loader.build()Build a newConfiginstance based on this builder instance.forClassLoader(ClassLoader loader) Specify the class loader for which this configuration is being built.<T> ConfigBuilderwithConverter(Class<T> type, int priority, Converter<T> converter) Add the specifiedConverterinstance for the given type to the configuration being built.withConverters(Converter<?>... converters) Add the specifiedConverterinstances to the configuration being built.withSources(ConfigSource... sources) Add the specifiedConfigSourceinstances to the configuration being built.
-
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
Specify the class loader for which this configuration is being built.- Parameters:
loader- the class loader- Returns:
- this configuration builder instance
-
withSources
Add the specifiedConfigSourceinstances to the configuration being built.- Parameters:
sources- the configuration sources- Returns:
- this configuration builder instance
-
withConverters
Add the specifiedConverterinstances 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
Add the specifiedConverterinstance 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
100if 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
-
build
Config build()Build a newConfiginstance based on this builder instance.- Returns:
- the new configuration object
-