private Class getCollectionContainedType(Method m) throws ClassNotFoundException{
String methodString = m.toGenericString();
if(methodString.indexOf("<")<0||methodString.indexOf(">")<0){
return Object.class;
}
else{
String classString = methodString.substring(methodString.indexOf("<")+1,
methodString.indexOf(">"));
return Class.forName(classString);
}
}
获取集合中范型类型的最简单的方法。
最新推荐文章于 2021-11-21 01:42:50 发布