Updated on 2026-08-14

This commit is contained in:
Tangem 2023-07-27 11:44:04 +03:00
parent ce57171f3b
commit ec07825276
22 changed files with 273 additions and 362 deletions

View file

@ -1,8 +1,14 @@
package com.tangem.utils.converter
interface Converter<I, O> {
interface Converter<I : Any, O : Any?> {
fun convert(value: I): O
fun convertList(input: List<I>): List<O> {
return input.map { convert(it) }
fun convertList(input: Collection<I>): List<O> {
return input.map(::convert)
}
fun convertSet(input: Collection<I>): Set<O> {
return input.mapTo(hashSetOf(), ::convert)
}
}

View file

@ -1,8 +1,10 @@
package com.tangem.utils.converter
interface TwoWayConverter<I, O> : Converter<I, O> {
interface TwoWayConverter<I : Any, O> : Converter<I, O> {
fun convertBack(value: O): I
fun convertListBack(input: List<O>): List<I> {
fun convertListBack(input: Collection<O>): List<I> {
return input.map { convertBack(it) }
}
}