This is the Javabeans mechanism. Properties are identified not by fields, but by getter (accessor) and / or setter (mutator) methods.
For more technical info, read the JavaBeans spec
Or have a look at this simple test class:
public class TestBean {
private String complete;
public String getComplete() { return complete; }
public void setComplete(final String complete) { this.complete = complete; }
private String getterOnly;
public String getGetterOnly() { return getterOnly; }
private String setterOnly;
public void setSetterOnly(final String setterOnly) { this.setterOnly = setterOnly; }
public String getNoBackingField() { return ""; }
}
and the simple JavaBeans analysis:
public class Test {
public static void analyzeBeanProperties(final Class<?> clazz) throws Exception {
for (final PropertyDescriptor propertyDescriptor
: Introspector.getBeanInfo(clazz, Object.class).getPropertyDescriptors()) {
System.out.println("Property name: " + propertyDescriptor.getName());
System.out.println("Getter method: " + propertyDescriptor.getReadMethod());
System.out.println("Setter method: " + propertyDescriptor.getWriteMethod());
System.out.println();
}
}
public static void main(final String[] args) throws Exception {
analyzeBeanProperties(TestBean.class);
}
}
Output:
Property name: complete
Getter method: public java.lang.String test.bean.TestBean.getComplete()
Setter method: public void test.bean.TestBean.setComplete(java.lang.String)
Property name: getterOnly
Getter method: public java.lang.String test.bean.TestBean.getGetterOnly()
Setter method: null
Property name: noBackingField
Getter method: public java.lang.String test.bean.TestBean.getNoBackingField()
Setter method: null
Property name: setterOnly
Getter method: null
Setter method: public void test.bean.TestBean.setSetterOnly(java.lang.String)