Converter

interface Converter<F, T> : ConvertsTo<F, T> , ConvertsFrom<F, T>

Models two-way conversion between a type T and a type F

Parameters

F

The type being converted from

T

The type being converted to

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

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, F2, T> Converter<F, T>.andThenFrom(converter: Converter<F2, F>): Converter<F2, T>

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, T2> Converter<F, T>.andThenTo(converter: Converter<T, T2>): Converter<F, T2>

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
abstract fun convertFrom(to: T): F

Converts a single value from type T to type F

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

Converts a single value from type F to type T

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, 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
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

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

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

Link copied to clipboard
fun <F, F2, T> Converter<List<F>, T>.mapFrom(elementConverter: Converter<F2, F>): Converter<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.)

fun <FK, FV, FK2, FV2, T> Converter<Map<FK, FV>, T>.mapFrom(entryConverter: Converter<Pair<FK2, FV2>, Pair<FK, FV>>): Converter<Map<FK2, FV2>, T>

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

fun <FK, FV, FK2, FV2, T> Converter<Map<FK, FV>, T>.mapFrom(keyConverter: Converter<FK2, FK>, valueConverter: Converter<FV2, FV>): Converter<Map<FK2, FV2>, T>

Chains this map converter with a key converter and 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.)

Link copied to clipboard
fun <FK, FK2, V, T> Converter<Map<FK, V>, T>.mapKeysFrom(keyConverter: Converter<FK2, FK>): Converter<Map<FK2, V>, T>

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, TK, TK2, V> Converter<F, Map<TK, V>>.mapKeysTo(keyConverter: Converter<TK, TK2>): Converter<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> Converter<F, List<T>>.mapTo(elementConverter: Converter<T, T2>): Converter<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> Converter<F, Map<TK, TV>>.mapTo(entryConverter: Converter<Pair<TK, TV>, Pair<TK2, TV2>>): Converter<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> Converter<F, Set<T>>.mapTo(elementConverter: Converter<T, T2>): Converter<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.)

fun <F, TK, TV, TK2, TV2> Converter<F, Map<TK, TV>>.mapTo(keyConverter: Converter<TK, TK2>, valueConverter: Converter<TV, TV2>): Converter<F, Map<TK2, TV2>>

Chains this map converter with a key converter and 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.)

Link copied to clipboard
fun <K, FV, FV2, T> Converter<Map<K, FV>, T>.mapValuesFrom(valueConverter: Converter<FV2, FV>): Converter<Map<K, FV2>, T>

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

Link copied to clipboard
fun <F, K, TV, TV2> Converter<F, Map<K, TV>>.mapValuesTo(valueConverter: Converter<TV, TV2>): Converter<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.)

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

Adds validation before conversions 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, T> Converter<F, T>.validatingTo(validate: (T) -> Unit): Converter<F, T>

Adds validation before conversions 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.