This commit is contained in:
Milos Kozak 2021-05-18 22:06:52 +02:00
parent 2e345a779e
commit 2251a20094

View file

@ -27,11 +27,11 @@ class Converters {
fun toSource(source: String?) = source?.let { Sources.fromString(it) } fun toSource(source: String?) = source?.let { Sources.fromString(it) }
@TypeConverter @TypeConverter
fun fromListOfXXXValueWithUnit(values: List<ValueWithUnit>): String = values.map(::ValueWithUnitWrapper) fun fromListOfValueWithUnit(values: List<ValueWithUnit>): String = values.map(::ValueWithUnitWrapper)
.let(SealedClassHelper.gson::toJson) .let(SealedClassHelper.gson::toJson)
@TypeConverter @TypeConverter
fun toMutableListOfXXXValueWithUnit(string: String): List<ValueWithUnit> = SealedClassHelper.gson fun toMutableListOfValueWithUnit(string: String): List<ValueWithUnit> = SealedClassHelper.gson
.fromJson<List<ValueWithUnitWrapper>>(string).map { it.wrapped } .fromJson<List<ValueWithUnitWrapper>>(string).map { it.wrapped }
private class ValueWithUnitWrapper(val wrapped: ValueWithUnit) private class ValueWithUnitWrapper(val wrapped: ValueWithUnit)