package com.gh.gamecenter.feature.room.converter;

import androidx.room.TypeConverter;

import com.gh.gamecenter.core.utils.GsonUtils;
import com.gh.gamecenter.feature.entity.ImageInfo;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.List;

public class ImageInfoConverter {
    @TypeConverter
    public static String toListString(List<ImageInfo> data) {
        return GsonUtils.toJson(data);
    }

    @TypeConverter
    public static List<ImageInfo> toList(String token) {
        Type type = new TypeToken<List<ImageInfo>>() {
        }.getType();
        return GsonUtils.getGson().fromJson(token, type);
    }
}
