Config
as the root object, that is, a substitution ${foo.bar}
will be replaced with the result of getValue("foo.bar")
. This method uses {@link ConfigResolveOptions#defaults()}, there is another variant {@link Config#resolve(ConfigResolveOptions)} which letsyou specify non-default options.
A given {@link Config} must be resolved before using it to retrieveconfig values, but ideally should be resolved one time for your entire stack of fallbacks (see {@link Config#withFallback}). Otherwise, some substitutions that could have resolved with all fallbacks available may not resolve, which will be potentially confusing for your application's users.
resolve()
should be invoked on root config objects, rather than on a subtree (a subtree is the result of something like config.getConfig("foo")
). The problem with resolve()
on a subtree is that substitutions are relative to the root of the config and the subtree will have no way to get values from the root. For example, if you did config.getConfig("foo").resolve()
on the below config file, it would not work:
common-value = 10 foo { whatever = ${common-value} }
Many methods on {@link ConfigFactory} such as{@link ConfigFactory#load()} automatically resolve the loadedConfig
on the loaded stack of config files.
Resolving an already-resolved config is a harmless no-op, but again, it is best to resolve an entire stack of fallbacks (such as all your config files combined) rather than resolving each one individually. @return an immutable object with substitutions resolved @throws ConfigException.UnresolvedSubstitution if any substitutions refer to nonexistent paths @throws ConfigException some other config exception if there are other problems
|
|
|
|
|
|
|
|
|
|