with Defaults
Creates a DSL scope that applies the provided default settings to all loaders defined inside.
Example (Kotlin DSL):
val config = Yacla.withDefaults(sharedSettings) {
loader<MainConfig> {
fromResource("/defaults/main.yml")
toFile(Paths.get("config/main.yml"))
}.config
}Content copied to clipboard
Return
the result returned from the provided block
Parameters
settings
common loader defaults such as parser, logger, and auto-update flag
block
a lambda with LoaderScope receiver to define one or more loaders
Creates a functional scope for defining multiple loaders with common defaults, for use in Java.
Example (Java):
LoaderSettings settings = new LoaderSettings(parser, logger, true);
MainConfig config = Yacla.withDefaults(settings, scope -> {
ConfigLoader<MainConfig> loader = scope.loader(MainConfig.class, b -> {
b.fromResource("/defaults/main.yml");
b.toFile(Paths.get("config/main.yml"));
});
return loader.getConfig();
});Content copied to clipboard
Return
the result returned from the provided function
Parameters
settings
common loader defaults such as parser, logger, and auto-update flag
block
function receiving a JLoaderScope for defining one or more loaders