Add: Room Converters (3/5 in replacing SQLite with Room)

This commit is contained in:
machiav3lli 2021-10-14 16:02:31 +02:00
parent 268d5be601
commit 1f48e0a548

View File

@ -71,55 +71,20 @@ class Lock {
class Converters { class Converters {
@TypeConverter @TypeConverter
fun toRepository(byteArray: ByteArray): Repository { fun toRepository(byteArray: ByteArray) = byteArray.jsonParse { Repository.deserialize(it) }
return byteArray.jsonParse {
Repository.deserialize(
0,//id,
it
)
}
}
@TypeConverter @TypeConverter
fun toByteArray(repository: Repository): ByteArray { fun toByteArray(repository: Repository) = jsonGenerate(repository::serialize)
return jsonGenerate(repository::serialize)
}
@TypeConverter @TypeConverter
fun toProduct(byteArray: ByteArray): Product { fun toProduct(byteArray: ByteArray) = byteArray.jsonParse { Product.deserialize(it) }
return byteArray.jsonParse {
Product.deserialize(
0,//repository_id,
"",//description,
it
)
}
}
@TypeConverter @TypeConverter
fun toByteArray(product: Product): ByteArray { fun toByteArray(product: Product) = jsonGenerate(product::serialize)
return jsonGenerate(product::serialize)
}
@TypeConverter @TypeConverter
fun toProductItem(byteArray: ByteArray): ProductItem { fun toProductItem(byteArray: ByteArray) = byteArray.jsonParse { ProductItem.deserialize(it) }
return byteArray.jsonParse {
ProductItem.deserialize(
0,//repository_id,
"",//package_name,
"",//name,
"",//summary,
"",//version,
true,//compatible,
true,//canUpdate,
0,//matchRank,
it
)
}
}
@TypeConverter @TypeConverter
fun toByteArray(productItem: ProductItem): ByteArray { fun toByteArray(productItem: ProductItem) = jsonGenerate(productItem::serialize)
return jsonGenerate(productItem::serialize)
}
} }