Config and
ConfigValue. Instances of Config and ConfigValue can
be combined into a single new instance using the
withFallback() method.
Do not implement this interface; it should only be implemented by the config library. Arbitrary implementations will not work because the library internals assume a specific concrete implementation. Also, this interface is likely to grow new methods over time, so third-party implementations will break.
| Modifier and Type | Method and Description |
|---|---|
| public ConfigMergeable | Returns: a new object (or the original one, if the fallback doesn't get used)an object whose keys should be used as fallbacks, if the keys
are not present in this one other)Returns a new value computed by merging this value with another, with keys in this value "winning" over the other one. |
| withFallback | back to summary |
|---|---|
| public ConfigMergeable withFallback(ConfigMergeable other) Returns a new value computed by merging this value with another, with keys in this value "winning" over the other one. This associative operation may be used to combine configurations from multiple sources (such as multiple configuration files). The semantics of merging are described in the spec for HOCON. Merging typically occurs when either the same object is created twice in the same file, or two config files are both loaded. For example:
foo = { a: 42 }
foo = { b: 43 }
Here, the two objects are merged as if you had written:
foo = { a: 42, b: 43 }
Only
foo = { a: 42 }
foo = 10
Here, the number 10 "wins" and the value of foo would be
simply 10. Again, for details see the spec.
| |