我不熟悉java beans框架,在下面的場景中,我得到了方法getFooWithX的IndexedPropertyDescriptor,有人可以解釋爲什麼嗎?爲什麼javabeans框架爲NON索引方法創建IndexedPropertyDescriptor
public class IntrospectorTest {
public static void main(String[] args) throws IntrospectionException {
BeanInfo info = Introspector.getBeanInfo(SubClass.class);
PropertyDescriptor[] descriptors = info.getPropertyDescriptors();
for (int i = 0; i < descriptors.length; i++) {
System.out.println(descriptors[i].getClass().getName() + ":" + descriptors[i].getName());
}
}
}
abstract class BaseClass {
public abstract Object getFoo();
}
abstract class SubClass extends BaseClass {
public Object getFooWithX(int x) {
return null;
}
}
和結果將是:
java.beans.PropertyDescriptor:class
java.beans.PropertyDescriptor:foo
java.beans.IndexedPropertyDescriptor:fooWithX
爲什麼?