Package-level declarations
The dev.lyzev.api.setting
package is a core component of the Kratos setting management library. It provides the necessary interfaces and classes to create and manage settings in your projects.
Usage Example
Setting
The Setting
class is the base class for all settings. It provides the necessary functionality to create and manage settings.
class BooleanSetting(
container: KClass<*>, name: String, description: String?, value: Boolean, hide: () -> Boolean = { false }, change: (Boolean) -> Unit = {}
) : Setting<Boolean>(container, name, description, value, hide, change)
Content copied to clipboard
Setting Manager
The SettingManager
class is responsible for managing settings. It provides the necessary functionality to create, register, and manage settings.
How to add a setting
SettingManager.settings += setting
Content copied to clipboard
Note: Settings are automatically registered when they are created. You do not need to manually register them.
How to get a setting
fun `test setting manager get by container class`() {
val setting = BooleanSetting(this::class, "test", true)
val retrievedSettings = SettingManager[this::class]
}
fun `test setting manager get by container class and name`() {
val setting = BooleanSetting(this::class, "test", true)
val retrievedSettings = SettingManager[this::class, "test"]
}
fun `test setting manager get by container class and type class`() {
val setting = BooleanSetting(this::class, "test", true)
val retrievedSetting = SettingManager.get(this::class, BooleanSetting::class, "test")
}
fun `test setting manager get by container and type`() {
val setting = BooleanSetting(this::class, "test", true)
val retrievedSetting = SettingManager.get(
"dev.lyzev.api.setting.test.SettingTests",
"dev.lyzev.api.setting.test.BooleanSetting",
"test"
)
}
Content copied to clipboard