Interface ConfigBuilder
@ProviderType
public interface ConfigBuilder
Builder for manually creating an instance of a
Config
.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionAdd the default config sources appearing on the builder's classpath including: System properties Environment properties /META-INF/microprofile-config.propertiesAdd the converters to be loaded via service loader patternAdd the config sources appearing to be loaded via service loader patternbuild()
Build theConfig
object.forClassLoader
(ClassLoader loader) Return the ConfigBuilder for a given classloader<T> ConfigBuilder
withConverter
(Class<T> type, int priority, Converter<T> converter) Add the specifiedConverter
for the given type.withConverters
(Converter<?>... converters) Add the specifiedConverter
.withSources
(ConfigSource... sources) Add the specifiedConfigSource
.
-
Method Details
-
addDefaultSources
ConfigBuilder addDefaultSources()Add the default config sources appearing on the builder's classpath including:- System properties
- Environment properties
- /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
Return the ConfigBuilder for a given classloader- Parameters:
loader
- the specified classloader- Returns:
- the ConfigureBuilder for the given classloader
-
withSources
Add the specifiedConfigSource
.- Parameters:
sources
- the config sources- Returns:
- the ConfigBuilder with the configured sources
-
withConverters
Add the specifiedConverter
. This method uses reflection to determine what type the converter is for. When using lambda expressions for custom converters you should usewithConverter(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
Add the specifiedConverter
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 convertpriority
- the priority of the converter (custom converters have a default priority of 100).converter
- the converter (can not benull
)- Returns:
- the ConfigBuilder with the added converters
-
build
Config build()Build theConfig
object.- Returns:
- the Config object
-