您的位置:首页 > 编程语言 > Go语言

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

2016-03-02 15:22 1001 查看
这种是类型转换中断。

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

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

private DataEntity<T> data;

@Override
public 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;
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: