百度一下啥也没有,先看看这个吧
老实说我没看懂
换个思路,传入demo,或者class
public static <T> void toIPageVo(IPage foIPage, IPageVo<T> iPageVo,T voDemo) throws InvocationTargetException, IllegalAccessException {
List foList = foIPage.getRecords();
List toList = new ArrayList<T>();
for (Object foRecord : foList) {
T vo=null;
try {
vo = (T) voDemo.getClass().newInstance();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
BeanUtilImpl.copyToVo(vo,foRecord);
toList.add(vo);
}
iPageVo.setRecords(toList);
iPageVo.setCurrent(foIPage.getCurrent());
iPageVo.setSize(foIPage.getSize());
iPageVo.setTotal(foIPage.getTotal());
iPageVo.setPages(foIPage.getPages());
}
public static <T> void toIPageVo(IPage foIPage, IPageVo<T> iPageVo,Class clazz) throws InvocationTargetException, IllegalAccessException {
List foList = foIPage.getRecords();
List toList = new ArrayList<T>();
for (Object foRecord : foList) {
T vo=null;
try {
vo = (T) clazz.newInstance();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
BeanUtilImpl.copyToVo(vo,foRecord);
toList.add(vo);
}
iPageVo.setRecords(toList);
iPageVo.setCurrent(foIPage.getCurrent());
iPageVo.setSize(foIPage.getSize());
iPageVo.setTotal(foIPage.getTotal());
iPageVo.setPages(foIPage.getPages());
}