From 1f48e0a54809b929439eea5b0d53458d23a1ce1f Mon Sep 17 00:00:00 2001 From: machiav3lli Date: Thu, 14 Oct 2021 16:02:31 +0200 Subject: [PATCH] Add: Room Converters (3/5 in replacing SQLite with Room) --- .../com/looker/droidify/database/Tables.kt | 47 +++---------------- 1 file changed, 6 insertions(+), 41 deletions(-) diff --git a/src/main/kotlin/com/looker/droidify/database/Tables.kt b/src/main/kotlin/com/looker/droidify/database/Tables.kt index fb4077e8..4d5e6705 100644 --- a/src/main/kotlin/com/looker/droidify/database/Tables.kt +++ b/src/main/kotlin/com/looker/droidify/database/Tables.kt @@ -71,55 +71,20 @@ class Lock { class Converters { @TypeConverter - fun toRepository(byteArray: ByteArray): Repository { - return byteArray.jsonParse { - Repository.deserialize( - 0,//id, - it - ) - } - } + fun toRepository(byteArray: ByteArray) = byteArray.jsonParse { Repository.deserialize(it) } @TypeConverter - fun toByteArray(repository: Repository): ByteArray { - return jsonGenerate(repository::serialize) - } + fun toByteArray(repository: Repository) = jsonGenerate(repository::serialize) @TypeConverter - fun toProduct(byteArray: ByteArray): Product { - return byteArray.jsonParse { - Product.deserialize( - 0,//repository_id, - "",//description, - it - ) - } - } + fun toProduct(byteArray: ByteArray) = byteArray.jsonParse { Product.deserialize(it) } @TypeConverter - fun toByteArray(product: Product): ByteArray { - return jsonGenerate(product::serialize) - } + fun toByteArray(product: Product) = jsonGenerate(product::serialize) @TypeConverter - fun toProductItem(byteArray: ByteArray): ProductItem { - return byteArray.jsonParse { - ProductItem.deserialize( - 0,//repository_id, - "",//package_name, - "",//name, - "",//summary, - "",//version, - true,//compatible, - true,//canUpdate, - 0,//matchRank, - it - ) - } - } + fun toProductItem(byteArray: ByteArray) = byteArray.jsonParse { ProductItem.deserialize(it) } @TypeConverter - fun toByteArray(productItem: ProductItem): ByteArray { - return jsonGenerate(productItem::serialize) - } + fun toByteArray(productItem: ProductItem) = jsonGenerate(productItem::serialize) } \ No newline at end of file