.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to

来源:互联网 发布:淘宝文案策划 编辑:程序博客网 时间:2024/05/22 15:37

这种是类型转换中断。

DataEntity 也必须要加<T>, 不光List<T>

否则类型转换会在 DataEntity 中断,导致类型转换异常。

private DataEntity<T> data;@Overridepublic String toString() {    return "BaseResults{" +            "data=" + data +            '}';}public DataEntity<T> getData() {    return data;}public List<T> getList() {    return data.rows;}public class DataEntity<T> {    @Override    public String toString() {        return "DataEntity{" +                "total=" + total +                ", rows=" + rows +                '}';    }    private int total;    private List<T> rows;    public void setTotal(int total) {        this.total = total;    }    public void setRows(List<T> rows) {        this.rows = rows;    }    public int getTotal() {        return total;    }    public List<T> getRows() {        return rows;    }}


0 0
原创粉丝点击