YamlParser

class YamlParser : ConfigParser

Default ConfigParser implementation for YAML configuration files.

This parser uses SnakeYAML Engine to parse and serialize YAML configuration data. It supports deserialization into Kotlin data classes (using primary constructors) or Java records (with optional NamedRecord annotation for component name mapping).

It also automatically registers a YamlUpdateStrategy for handling configuration updates.

Typically passed to net.ririfa.yacla.loader.ConfigLoaderBuilder.parser when using Yacla with YAML.

Example:

val loader = Yacla.loader<MyConfig>()
.fromResource("/defaults/config.yml")
.toFile(Paths.get("config.yml"))
.parser(YamlParser())
.load()

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
open override val supportedExtensions: Set<String>

Functions

Link copied to clipboard
open override fun parse(input: InputStream): Map<String, Any>

Parses YAML content from the given InputStream into a Map of key-value pairs.

Link copied to clipboard
open override fun <T : Any> write(output: OutputStream, config: T)

Serializes the given configuration object into YAML and writes it to the output stream.