GreeDao保存List对象列表

2018-03-01  本文已影响0人  AppMonkey
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;
上一篇 下一篇

猜你喜欢

热点阅读