Top Description Methods
org.eclipse.microprofile.config.spi

public Interface ConfigBuilder

Annotations
@ProviderType
Imports
org.eclipse.microprofile.config.Config

A builder for manually creating a configuration instance.
Authors
Romain Manni-Bucau, Mark Struberg, Emily Jiang
See Also
ConfigProviderResolver#getBuilder()

Method Summary

Modifier and TypeMethod and Description
public ConfigBuilder

Returns:

this configuration builder instance
addDefaultSources
()

Add the default configuration sources to the configuration being built.

public ConfigBuilder

Returns:

this configuration builder instance
addDiscoveredConverters
()

Add all configuration converters which can be discovered from this configuration builder's class loader.

public ConfigBuilder

Returns:

this configuration builder instance
addDiscoveredSources
()

Add all configuration sources which can be discovered from this configuration builder's class loader.

public Config

Returns:

the new configuration object
build
()

Build a new Config instance based on this builder instance.

public ConfigBuilder

Returns:

this configuration builder instance
forClassLoader
(ClassLoader
the class loader
loader
)

Specify the class loader for which this configuration is being built.

public <
the type to convert
T
>
ConfigBuilder

Returns:

this configuration builder instance
withConverter
(Class<T>
the class of the type to convert
type
,
int
the priority of the converter
priority
,
Converter<T>
the converter (can not be null)
converter
)

Add the specified Converter instance for the given type to the configuration being built.

public ConfigBuilder

Returns:

this configuration builder instance
withConverters
(Converter<?>...
the converters to add
converters
)

Add the specified Converter instances to the configuration being built.

public ConfigBuilder

Returns:

this configuration builder instance
withSources
(ConfigSource...
the configuration sources
sources
)

Add the specified ConfigSource instances to the configuration being built.

Method Detail

addDefaultSourcesback to summary
public ConfigBuilder addDefaultSources()

Add the default configuration sources to the configuration being built.

Returns:ConfigBuilder

this configuration builder instance

addDiscoveredConvertersback to summary
public ConfigBuilder addDiscoveredConverters()

Add all configuration converters which can be discovered from this configuration builder's class loader.

Returns:ConfigBuilder

this configuration builder instance

addDiscoveredSourcesback to summary
public ConfigBuilder addDiscoveredSources()

Add all configuration sources which can be discovered from this configuration builder's class loader.

Returns:ConfigBuilder

this configuration builder instance

buildback to summary
public Config build()

Build a new Config instance based on this builder instance.

Returns:Config

the new configuration object

forClassLoaderback to summary
public ConfigBuilder forClassLoader(ClassLoader loader)

Specify the class loader for which this configuration is being built.

Parameters
loader:ClassLoader

the class loader

Returns:ConfigBuilder

this configuration builder instance

withConverterback to summary
public <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.

Parameters
<T>
the type to convert
type:Class<T>

the class of the type to convert

priority:int

the priority of the converter

converter:Converter<T>

the converter (can not be null)

Returns:ConfigBuilder

this configuration builder instance

withConvertersback to summary
public 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:Converter<?>[]

the converters to add

Returns:ConfigBuilder

this configuration builder instance

withSourcesback to summary
public ConfigBuilder withSources(ConfigSource... sources)

Add the specified ConfigSource instances to the configuration being built.

Parameters
sources:ConfigSource[]

the configuration sources

Returns:ConfigBuilder

this configuration builder instance