TomlMapperConfigurator

Functions

Link copied to clipboard
inline fun <T : TomlValue, R : Any> decoder(crossinline decoder: TomlDecoder.(tomlValue: T) -> R?)

Convenience overload for decoder, for when you don't need to consider the full target KType.

inline fun <T : TomlValue, R : Any> decoder(noinline decoder: TomlDecoder.(targetType: KType, tomlValue: T) -> R?)

Configures a custom decoder function for the given Kotlin type. A custom decoder function is a function from a TomlValue and a KType representing a target type, to that target type. Custom decoder functions are associated with a KClass representing that target type.

fun <T : Any> decoder(kClass: KClass<T>, decoder: TomlDecoder.(targetType: KType, tomlValue: TomlValue) -> Any?)
Link copied to clipboard
fun <T : Any> default(defaultValue: T)

Set the given defaultValue as the default for any missing members of data class T. Any time an object of type T is being decoded but the TOML document is missing one or more fields needed to construct the object, that value will be fetched from the default value.

Link copied to clipboard
inline fun <T : Any> encoder(noinline encoder: TomlEncoder.(kotlinValue: T) -> TomlValue)

Configures a custom encoder function for the given Kotlin type. A custom encoder function is a function from some Kotlin value to a TomlValue. Custom encoder functions are associated with a KClass representing the source type.

fun <T : Any> encoder(kClass: KClass<T>, encoder: TomlEncoder.(kotlinValue: Any) -> TomlValue)
Link copied to clipboard
inline fun <T : Any> mapping(vararg mappings: Pair<TomlName, KotlinName>)

Configures a custom property mapping for the type Kotlin type T, where T is any class with a primary constructor.

fun <T : Any> mapping(kClass: KClass<T>, mappings: List<Pair<TomlName, KotlinName>>)

Extensions

Link copied to clipboard

Delegate the handling of the given type to the given mapper. Overrides any previous configuration for that type, and will be overridden in turn by any subsequent configuration.