Class ConfigSources.MapBuilder

  • All Implemented Interfaces:
    Builder<ConfigSource>, Supplier<ConfigSource>
    Enclosing class:
    ConfigSources

    public static final class ConfigSources.MapBuilder
    extends Object
    implements Builder<ConfigSource>
    Builder of a 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:

    • Each Map key or Properties property name is the fully-qualified dotted-name format key for the corresponding Config node.
    • Each Map value or Properties property value is the corresponding value of the corresponding Config node.
    By default, if the provided 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.