public <T> T getResultData(Result<?> result,Class<T> clazz) {
T ret = null ;
if (result != null) {
if (!ResultEnum.SUCCESS.code.equals(result.getRetCode())) {
log.error(result.getRetMsg());
throw new LogicException(result.getRetMsg());
} else if (null != result.getData()) {
//return (T) result.getData();
}
}
try{
ret = clazz.newInstance();
}catch (Exception e){
log.error("getResultData类转换异常!");
throw new LogicException("getResultData类转换异常!");
}
return ret;
}
JAVA T 范型使用例子
最新推荐文章于 2024-04-11 18:46:44 发布