Package org.apache.juneau.marshall.hocon
Class HoconResolver
java.lang.Object
org.apache.juneau.marshall.hocon.HoconResolver
Resolves ${var} and ${?var} substitutions in the parsed HOCON tree.
Resolution algorithm: single-pass depth-first over the tree. Substitutions reference paths in the root object (e.g., ${database.host}). Optional substitutions (${?var}) are silently removed if the path does not exist. Required substitutions (${var}) throw if the path is missing. Circular references are detected and cause an error.
See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionLooks up a dotted path in the root object.voidresolve()Resolves all substitutions in-place in the tree.resolveConcatWithLookup(HoconValue.HoconConcat concat, Function<String, HoconValue> lookup) Resolves a concatenation value with a custom lookup (for self-referential substitution).
-
Constructor Details
-
HoconResolver
Constructor.- Parameters:
root- The root HOCON object (after parsing, before resolution).
Must not benull (resolve()dereferences it).
-
-
Method Details
-
resolve
Resolves all substitutions in-place in the tree.- Throws:
RuntimeException- If a required substitution path is missing or circular.
-
lookup
Looks up a dotted path in the root object.- Parameters:
path- The path (e.g., "database.host").
Can benull (returnsnull ).- Returns:
- The value at that path, or
null if the path isnull , blank, or does not resolve to an existing value.
-
resolveConcatWithLookup
public HoconValue resolveConcatWithLookup(HoconValue.HoconConcat concat, Function<String, HoconValue> lookup) Resolves a concatenation value with a custom lookup (for self-referential substitution). When the concat contains ${path}, the lookup is used instead of the root object. This allowspath = ${path}"/bin"to append to the previous value.- Parameters:
concat- The concatenation to resolve.
Must not benull .lookup- Custom lookup; for path X returns the value to use (e.g. previous value for self-ref).
Must not benull .- Returns:
- The resolved string value.
-