ConvertsFrom

fun interface ConvertsFrom<F, T>

Models one-way conversion from a type T to a type F. This type is similar to ConvertsTo but models conversion in the opposite direction.

Parameters

F

The type being converted to

T

The type being converted from

Inheritors

Functions

Link copied to clipboard
abstract fun convertFrom(to: T): F

Converts a single value from type T to type F

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> ConvertsFrom<F, T>.firstValidatingTo(validate: (T) -> Unit): ConvertsFrom<F, T>

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

Link copied to clipboard
fun <F, F2, T> ConvertsFrom<List<F>, T>.mapConvertsFrom(elementConverter: ConvertsFrom<F2, F>): ConvertsFrom<List<F2>, T>

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.)

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, F2, T> ConvertsFrom<Set<F>, T>.mapConvertsFrom(elementConverter: ConvertsFrom<F2, F>): ConvertsFrom<Set<F2>, T>

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

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

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.)