我正在玩 Doclets,我遇到了下一个问题。我想从一个类中获取属性,我认为参数方法会有所帮助。我的代码看起来像下一个(我正在为方法的返回类型这样做):
ClassDoc retType = pMethod.returnType().asClassDoc();
if(retType == null) {
System.out.println("No returnType for method " + pMethod.name());
return false;
} else {
System.out.println("returnType for method "
+ pMethod.name() + " is from type " + pMethod.returnType().typeName());
}
FieldDoc[] fields = retType.fields();
System.out.println("fields length for type " +
retType.name() + " is " + fields.length);
我得到的是
方法 myMethod 的 returnType 来自类型 MyMethodResponse
fields length for type MyMethodResponse is 0
也许我错过了一些东西。ClassDoc.fields() 方法不会给我带来所有属性列表吗?有没有办法做到这一点?非常感谢你。