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.SimpleGame

class SimpleGameListConverter {
    @TypeConverter
    fun toSimpleGameString(data: ArrayList<SimpleGame>?): String {
        return data?.toJson() ?: ""
    }

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