package com.gh.gamecenter.room.converter

import androidx.room.TypeConverter
import com.gh.gamecenter.common.utils.toJson
import com.gh.gamecenter.common.utils.toObject
import com.gh.gamecenter.feature.entity.ApkEntity

class ApkArrayListConverter {
    @TypeConverter
    fun toApkString(data: ArrayList<ApkEntity>?): String {
        return data?.toJson() ?: ""
    }

    @TypeConverter
    fun toApkEntity(data: String?): ArrayList<ApkEntity> {
        val apkArray = data?.toObject() ?: arrayOf<ApkEntity>()
        return ArrayList(apkArray.toList())
    }
}