Java Bean Properties are defined by methods, not fields. For this reason, the PropertyDescriptor class has getReadMethod() and getWriteMethod() , but not getField() methods.
Personally, I think your colleague is using bad practice.
a) is is a verb. Fields should not be named after verbs.
b) while this is not required, it is good practice to call a field like a property that allows you to write code as follows:
PropertyDescriptor pd; // let assume this is set Method referenceMethod = pd.getReadMethod() == null // at least one of these is not null ? pd.getWriteMethod() : pd.getReadMethod(); Field underLyingField = referenceMethod .getDeclaringClass() .getDeclaredField(pd.getName());
Although this code is not standardized, it complies with the rules and can be very convenient. If you do not follow such conventions, you have no way to associate a field with a property (which is intentional, I know).
eg. I use the code as above to check if there are annotations in the field
About indexed properties:
Index syntax can be used for array or list (or map) properties, but only if they are defined as standard Bean properties.
So, if you have a property like this:
private String[] bar; public String[] getBar(){ return bar; } public void setBar(String[] bar){ this.bar = bar; }
or like this:
private List<String> bar; public List<String> getBar(){ return bar; } public void setBar(List<String> bar){ this.bar = bar; }
you can access the first element with the expression ${bar[0]}
And with this map property:
private Map<String, String> bar; public Map<String, String> getBar(){ return bar; } public void setBar(Map<String, String> bar){ this.bar = bar; }
You can access the value converted to "baz" , like this ${bar['baz']} .
This functionality is built on top of the standard beans functionality, so it requires regular getters / setters.