DefaultConfigLoader

class DefaultConfigLoader<T : Any>(clazz: Class<T>, parser: ConfigParser, file: Path, logger: YaclaLogger?, resourcePath: String) : ConfigLoader<T>

Default implementation of ConfigLoader that loads, validates, and updates a configuration object from a file using a ConfigParser.

This loader handles the following:

  • Loading the configuration object from a file

  • Performing null/default value injection for missing fields

  • Validating fields based on annotations such as Required, Range, and Default

  • Automatically applying update strategies registered for the parser type

Typically created via a net.ririfa.yacla.loader.ConfigLoaderBuilder, not instantiated directly.

Parameters

T

the type of the configuration object

clazz

the target configuration class

parser

the parser to deserialize the configuration

file

the path to the configuration file

logger

optional logger for diagnostics

resourcePath

the path to the resource used for updating configs

Constructors

Link copied to clipboard
constructor(clazz: Class<T>, parser: ConfigParser, file: Path, logger: YaclaLogger?, resourcePath: String)

Properties

Link copied to clipboard
open override var config: T

The loaded configuration object.

Functions

Link copied to clipboard
fun <T : Any> constructConfig(clazz: Class<T>, rawMap: Map<String, Any?>): T
Link copied to clipboard
open override fun reload(): ConfigLoader<T>

Reloads the configuration object from the backing file.

Link copied to clipboard
open override fun updateConfig(): ConfigLoader<T>

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

Link copied to clipboard
open override 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.