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.entity.TagInfoEntity

class TagInfoListConverter {
    @TypeConverter
    fun toTagInfoString(data: ArrayList<TagInfoEntity>?): String {
        return data?.toJson() ?: ""
    }

    @TypeConverter
    fun toTagInfoEntity(data: String?): ArrayList<TagInfoEntity> {
        val array = data?.toObject() ?: arrayOf<TagInfoEntity>()
        return ArrayList(array.toList())
    }
}