ConfigLoader

interface ConfigLoader<T : Any>

Represents a loaded configuration file mapped to a Kotlin or Java object.

Provides access to the deserialized configuration object and lifecycle operations such as reloading, validation, filling default values, and updating the file from the default resource if outdated.

This interface is typically obtained by calling ConfigLoaderBuilder.load.

Example usage:

val loader = Yacla.loader<MyConfig>()
.fromResource("/defaults/config.yml")
.toFile(Paths.get("config.yml"))
.parser(SnakeYamlParser())
.withLogger(ConsoleLogger())
.autoUpdateIfOutdated(true)
.load()

loader.validate()
loader.nullCheck()
val config = loader.config

Parameters

T

the type of the configuration object

Inheritors

Properties

Link copied to clipboard
abstract val config: T

The loaded configuration object.

Functions

Link copied to clipboard
abstract fun reload(): ConfigLoader<T>

Reloads the configuration object from the backing file.

Link copied to clipboard
abstract fun updateConfig(): Boolean

Attempts to update the configuration file by merging the default resource with the current file, preserving user-defined values.

Link copied to clipboard
abstract fun validate(): ConfigLoader<T>

Validates the configuration object based on field annotations such as net.ririfa.yacla.annotation.Required and net.ririfa.yacla.annotation.Range.