Package-level declarations

Types

Link copied to clipboard
interface Converter<F, T> : ConvertsTo<F, T> , ConvertsFrom<F, T>

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

Link copied to clipboard
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.

Link copied to clipboard
fun interface ConvertsTo<F, T>

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

Link copied to clipboard

Models partial, asymmetrical conversion between a type F and a type T, where some condition internal to the converter splits the possible pathways data make take through conversion logic. One of these branches will be more complex and involve converting types F and T to types F2 and T2 (respectively). The remaining conversion between F2 and T2 will typically be delegated to another converter.

Functions

Link copied to clipboard
fun <F, T> Converter(convertTo: ConvertsTo<F, T>, convertFrom: ConvertsFrom<F, T>): Converter<F, T>

Creates a new two-way converter from symmetrical one-way converters

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

Merges this SplittingConverter by delegating to a Converter instance that converts between types F2 and T2. After the merge, a new Converter will be returned which fully converts between types F and T.

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.