美文网首页
GreeDao保存List对象列表

GreeDao保存List对象列表

作者: AppMonkey | 来源:发表于2018-03-01 12:04 被阅读0次
public class GsonConverter implements PropertyConverter<List<SceneBulb>, String>{
    @Override
    public List<SceneBulb> convertToEntityProperty(String databaseValue) {
        if(databaseValue == null) return null;
        return new Gson().fromJson(databaseValue, new TypeToken<List<SceneBulb>>(){}.getType());
    }

    @Override
    public String convertToDatabaseValue(List<SceneBulb> entityProperty) {
        if(entityProperty == null) return null;
        return new Gson().toJson(entityProperty);
    }
}

@Convert(columnType = String.class, converter = GsonConverter.class)
private List<SceneBulb> devicelist;

相关文章

  • GreeDao保存List对象列表

  • Numpy学习笔记

    1 List、Array、NumPy数值处理方法比较 1.1 List的三个缺点 列表可以是任何对象 列表中所保存...

  • python数据结构

    列表(list) 列表是以固定顺序保存对象的容器,列表用方括号表示,列表可以保存任意数据类型,是可变数据结构,可以...

  • 2020-07-28

    列表 列表用list表示,有序集合,没有固定大小,能够保存任意数量任意类型的 Python 对象 语法为[元素1,...

  • python中的二维数组表示(list与numpy.array)

    1.list为python中最为常见的数据结构,list的元素可以是任何对象,因此列表中所保存的是对象的指针。 ...

  • List> list = new ArrayLi

    在JAVA集合框架中。通常我们使用接口List引用来指向ArrayList对象,如下所示 当使用列表保存列表时,如...

  • 2018-07-21-python-列表

    列表: [ ]空列表 [1,2,3] list() list(可迭代对象) list(‘abcd’) list(r...

  • 2.6.1 列表(list)

    2.6.1 列表(list) 1.列表构造:对象的集合,元素可以是任意对象类型。 Lst<-list(name="...

  • Python Numpy全世界最长基础教程最适合小白比全球的还长

    标准安装的Python中用列表(list)保存一组值,可以用来当作数组使用,不过由于列表的元素可以是任何对象,因此...

  • Python学习记录2

    数据结构介绍 列表 list 1、用[]创建,没有固定大小,可以保存任意数量和类型的对象(同一个列表也可以包含不同...

网友评论

      本文标题:GreeDao保存List对象列表

      本文链接:https://www.haomeiwen.com/subject/gvrgxftx.html