wrapConfig
Wraps an arbitrary YAML file for use in AbstractConfig.
Uses snakeyaml-engine (YAML 1.2) internally. This means only true/false are booleans — yes/no/on/off are treated as strings.
Saving keeps the comments of the file: comments, blank lines and the quoting of every value that was not changed programmatically are written back as loaded. A changed value keeps the comments of its key, a removed key loses its comments. Comment lines at the top of the file that are separated from the first key by a blank line are the file header and stay at the top. Comments of a key can also be read and replaced programmatically. Indentation and line layout are normalized: nested entries are indented by two spaces, aliases (*name) are written as copies of their value, strings with line breaks are written double-quoted on one line, and a flow mapping ({a: 1}) that gets new keys or comments is written in block style.
String getters and getMap return values as typed in the file: 1.10, 007 and True are read as "1.10", "007" and "True", while the numeric and boolean getters parse them. Values set programmatically are converted with toString.
Type coercion is applied when reading values: lossless conversions (e.g. Int to Long, any scalar to String) succeed silently. Lossy or impossible conversions log a warning and return the registered default. A key that is present without a value reads as an empty list or map, and as the default for any other type.
This implementation is not thread-safe. Callers must ensure that reads, writes, reloads, and saves are not performed concurrently from multiple threads.
Throws
if the file cannot be read (not UTF-8, no permission), contains invalid YAML or an alias that includes itself
Wraps an arbitrary YAML file for use in AbstractConfig.
Parameters
Path to the YAML configuration file
Logger for warnings about invalid configuration values
See also
Throws
if the file cannot be read (not UTF-8, no permission), contains invalid YAML or an alias that includes itself