mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 19:32:16 +00:00
Add: Room Converters (3/5 in replacing SQLite with Room)
This commit is contained in:
parent
268d5be601
commit
1f48e0a548
@ -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)
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user