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

class ActivityLabelListConverter {
    @TypeConverter
    fun toActivityLabelString(data: ArrayList<ActivityLabelEntity>?): String {
        return data?.toJson() ?: ""
    }

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