java.util.function.Supplier<ConfigSource>
public static final class ConfigSources.MapBuilder extends java.lang.Object implements java.util.function.Supplier<ConfigSource>
ConfigSource
based on a Map
containing
config entries.
The caller constructs a MapBuilder
with either a Map
or a
Properties
object. The builder uses the Map
entries or
Properties
name/value pairs to create config entries:
Map
key or Properties
property name is the
fully-qualified dotted-name format key for the corresponding
Config
node.
Map
value or Properties
property value is the
corresponding value of the corresponding Config
node.
Map
or Properties
object
contains duplicate keys then the Source.load()
on the
returned ConfigSource
will fail. The caller can invoke
lax()
to relax this restriction, in which case the
load
operation will log collision warnings but continue.
For example, the following properties collide:
app.port = 8080
app = app-name
The MapConfigSource
returned by build()
and get()
works with an immutable copy of original map; it does
not support
ConfigSource mutability
.
Modifier and Type | Method | Description |
---|---|---|
ConfigSource |
build() |
Builds new instance of
MapConfigSource from the Map
or Properties passed to a constructor. |
ConfigSource |
get() |
|
ConfigSources.MapBuilder |
lax() |
Switches off strict mode.
|
public ConfigSources.MapBuilder lax()
In lax mode Source.load()
does not fail if config keys
collide; it logs warnings and continues.
public ConfigSource build()
MapConfigSource
from the Map
or Properties
passed to a constructor.MapConfigSource
based on the specified Map
or Properties
public ConfigSource get()
get
in interface java.util.function.Supplier<ConfigSource>
Copyright © 2018 Oracle Corporation. All rights reserved.