Converters

String-to-value converters used by generated loaders. Every converter throws IllegalArgumentException (or a subclass) on invalid input, which the loader turns into ConfigError.ConversionFailed.

Functions

Link copied to clipboard

Accepts true/false, yes/no, on/off and 1/0, case-insensitively.

Link copied to clipboard

Parses 30s, 1h 30m, 500ms or ISO-8601 (PT30S), see Duration.parse.

Link copied to clipboard
fun <E : Enum<E>> enumOf(entries: List<E>, raw: String): E

Matches an enum constant by name, case-insensitively. Dashes are treated as underscores.

Link copied to clipboard
fun <T> list(raw: String, element: (String) -> T): List<T>

Parses a comma-separated list: a, b, c. Surrounding brackets and quotes are accepted, so TOML and YAML inline arrays such as ["a", "b"] work too. A blank value is an empty list.

Link copied to clipboard
fun <T> map(raw: String, value: (String) -> T): Map<String, T>

Parses key=value pairs separated by commas: a=1, b=2. Surrounding braces are accepted, and : works as a separator too. For TOML tables and YAML mappings, which sources flatten into name.key entries, the loader uses mapEntries instead.

Link copied to clipboard
fun <T> mapEntries(entries: Map<String, String>, value: (String) -> T): Map<String, T>

Converts the child entries of a table or mapping, see ConfigSource.children.