Skip to main content


A Mapper defines a function to map a value from a type to another type.

interface Mapper<in From, out To> {
fun map(from: From): To

Mapping Arrays & Dictionaries

When the languages enables it, Mapper has extensions to map arrays and dictionaries. Otherwise, you will have to implement a custom mapper to map the values included in arrays and dictionaries.

Find below some of the supported extensions:

fun <From, To> Mapper<From, To>.map(values: List<From>): List<To> = { ... }
fun <From, To, K> Mapper<From, To>.map(value: Map<K, From>): Map<K, To> { ... }

Default implementations

Harmony has multiple pre-defined implementations of mapper.

  • VoidMapper: Empty implementation that returns en error.
  • CastMapper<In,Out>: Mapping by casting the object into the given types.
  • ClosureMapper<In,Out>: Mapper that has a closure/lambda upon initialization specifiying the mapping action.

Every Harmony library has its own set of pre-defined mappers. Before creating a new mapper, check always with the available mappers in your language.