mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 11:22:12 +00:00
Improve: Recommended to use objects for converter (Jetcaster-sample)
This commit is contained in:
parent
4b1639a2cd
commit
37bcadedd2
@ -76,22 +76,28 @@ class Lock {
|
|||||||
var version_code = 0
|
var version_code = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
class Converters {
|
object Converters {
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
|
@JvmStatic
|
||||||
fun toRepository(byteArray: ByteArray) = byteArray.jsonParse { Repository.deserialize(it) }
|
fun toRepository(byteArray: ByteArray) = byteArray.jsonParse { Repository.deserialize(it) }
|
||||||
|
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
|
@JvmStatic
|
||||||
fun toByteArray(repository: Repository) = jsonGenerate(repository::serialize)
|
fun toByteArray(repository: Repository) = jsonGenerate(repository::serialize)
|
||||||
|
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
|
@JvmStatic
|
||||||
fun toProduct(byteArray: ByteArray) = byteArray.jsonParse { Product.deserialize(it) }
|
fun toProduct(byteArray: ByteArray) = byteArray.jsonParse { Product.deserialize(it) }
|
||||||
|
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
|
@JvmStatic
|
||||||
fun toByteArray(product: Product) = jsonGenerate(product::serialize)
|
fun toByteArray(product: Product) = jsonGenerate(product::serialize)
|
||||||
|
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
|
@JvmStatic
|
||||||
fun toProductItem(byteArray: ByteArray) = byteArray.jsonParse { ProductItem.deserialize(it) }
|
fun toProductItem(byteArray: ByteArray) = byteArray.jsonParse { ProductItem.deserialize(it) }
|
||||||
|
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
|
@JvmStatic
|
||||||
fun toByteArray(productItem: ProductItem) = jsonGenerate(productItem::serialize)
|
fun toByteArray(productItem: ProductItem) = jsonGenerate(productItem::serialize)
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user