Updated on 2026-08-14
This commit is contained in:
parent
ce57171f3b
commit
ec07825276
22 changed files with 273 additions and 362 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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) }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue