public static <T> List<T> parseList(String xlsName, String sheetName);
使用时不需要指定泛型类型,参考自guva。
public <T> T newInstantce() {
Type genType = getClass().getGenericSuperclass();
Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
Class<T> clazz = (Class) params[0];
T obj = null;
try {
obj = clazz.newInstance();
} catch (Exception e) {
e.printStackTrace();
log.error(“ERROR”, e);
}
return obj;
}
生成泛型的实例。
0 条评论。