我有一个 JSON 需要使用 ObjectMapper 读入对象。它看起来像这样:
private final ObjectMapper mapper = new ObjectMapper();
Report<? extends BaseLog> toReport(String json) throws IOException {
return mapper.readValue(json, Report.class);
}
同时,IDEA 发誓要参数化,他们说,Unchecked Assignment
也就是说,它希望我Report
完全是<? extends BaseLog>
.
这是我理解它不起作用的方式:
Report<? extends BaseLog> toReport(String json) throws IOException {
return mapper.readValue(json, Report<? extends BaseLog>.class);
}
对象映射时如何参数化?
使用类型引用