我在下面有一个界面:
interface Find {
List<String> getParams();
}
我有一个简单的POJO课程如下:
public class FindSystem<T extends Find> {
private List<String> params;
private Class<T> clazz;
public List<String> setParams(List<String> params) {
...
}
public List<String> getParams() {
...
}
public Class<T> getClazz() {
return clazz;
}
public find setClazz(Class<T> clazz) {
this.clazz = clazz;
return this;
}
}
我有一个服务类:
public class FindService<T extends Find> {
public fetch(Class<T> class) {
FindSystem<T> f = new FindSystem<T>();
f.setClazz(clazz);
Find en = f.getClazz().newInstance();
f.setParams(en.getParams());
}
}
我有一个Controller类,其中System是映射到数据库中表的实体类:
@Path("/find")
public class FindController {
@Inject
FindService<System> systemservice; //Getting error here Bound Mismatch, the type System is not a valid substitute for the bounded parameter <T extends Find> of the type FindService<T>
...
}
获取错误:
FindService<System> systemservice;
//绑定不匹配,类型System不是FindService类型的有界参数的有效替代