Loader

annotation class Loader(val value: KClass<out FieldLoader>)

Specifies a custom FieldLoader for this field.

The referenced class must implement FieldLoader and have a no-argument constructor. It is instantiated via reflection and its FieldLoader.load method is called with the raw parsed value before any built-in type coercion.

Example:

class MyCustomLoader : FieldLoader {
override fun load(raw: Any?): Any? = raw?.toString()?.trim()
}

data class MyConfig(
@Loader(MyCustomLoader::class) val value: String? = null
)

Properties

Link copied to clipboard