ConvertsTo

fun interface ConvertsTo<F, T>

Models one-way conversion from a type F to a type T

Parameters

F

The type being converted from

T

The type being converted to

Inheritors

Functions

Link copied to clipboard
abstract fun convertTo(from: F): T

Converts a single value from type F to type T

Inherited functions

Link copied to clipboard

Chains this converter with another converter, yielding a new converter which performs a two-stage conversion. (Note that these two "stages" are conceptual. Each of these stages may consist of multiple logical steps in their actual implementation.)

Link copied to clipboard
fun <F, T> ConvertsTo<F, T>.firstValidatingFrom(validate: (F) -> Unit): ConvertsTo<F, T>

Adds validation before a conversion by running validate on F values before converting them to type T. Validators are expected to throw an exception if the expected condition is not met.

Link copied to clipboard
fun <F, TK, TK2, V> ConvertsTo<F, Map<TK, V>>.mapConvertsKeysTo(keyConverter: ConvertsTo<TK, TK2>): ConvertsTo<F, Map<TK2, V>>

Chains this map converter with a key converter, yielding a new converter which performs a two-stage mapping conversion. (Note that these two "stages" are conceptual. Each of these stages may consist of multiple logical steps in their actual implementation.)

Link copied to clipboard
fun <F, T, T2> ConvertsTo<F, List<T>>.mapConvertsTo(elementConverter: ConvertsTo<T, T2>): ConvertsTo<F, List<T2>>

Chains this list converter with an element converter, yielding a new converter which performs a two-stage mapping conversion. (Note that these two "stages" are conceptual. Each of these stages may consist of multiple logical steps in their actual implementation.)

fun <F, TK, TV, TK2, TV2> ConvertsTo<F, Map<TK, TV>>.mapConvertsTo(entryConverter: ConvertsTo<Pair<TK, TV>, Pair<TK2, TV2>>): ConvertsTo<F, Map<TK2, TV2>>

Chains this map converter with an entry converter, yielding a new converter which performs a two-stage mapping conversion. (Note that these two "stages" are conceptual. Each of these stages may consist of multiple logical steps in their actual implementation.)

fun <F, T, T2> ConvertsTo<F, Set<T>>.mapConvertsTo(elementConverter: ConvertsTo<T, T2>): ConvertsTo<F, Set<T2>>

Chains this set converter with an element converter, yielding a new converter which performs a two-stage mapping conversion. (Note that these two "stages" are conceptual. Each of these stages may consist of multiple logical steps in their actual implementation.)

Link copied to clipboard
fun <F, K, TV, TV2> ConvertsTo<F, Map<K, TV>>.mapConvertsValuesTo(valueConverter: ConvertsTo<TV, TV2>): ConvertsTo<F, Map<K, TV2>>

Chains this map converter with a value converter, yielding a new converter which performs a two-stage mapping conversion. (Note that these two "stages" are conceptual. Each of these stages may consist of multiple logical steps in their actual implementation.)