I've just read some jGoodies docs. It seems poewrful but it does have a problem: property names have to be specified as strings, so the compiler cannot enforce static type checking and refactoring becomes a nightmare.
PropertyConnector pc = new PropertyConnector(bean, "value", uicomp, "value");
I'm surprised no one has invented something better yet, and I hope it was my fault when I searched for it. I mean, if you can get a Class reference from the language with
MyBean.class;
it seems obvious you could do the same also with field members of a class, something like:
java.lang.reflect.Field myBeanProp = MyBean.fieldname.field;
I understand that this would require the compiler to understand each field name as a keyword, and also that the above syntax is somewhat ambiguous, but I guess those problems can be worked around by using a new single fixed operator with two arguments, name it "property", something like the instanceof operator. I imagine something like:
java.lang.reflect.Field myBeanProp = MyBean property fieldname;
This way refactoring can take place with standard IDEs tools and the Field instance has more chances to carry enough static type informations than a String so that the compiler can enforce type checking.
Do you know if something like this already exists? Do you know if JSR 295 is going to address these issues? If it does not, what do you think about this idea?
Your feedback is very appreciated.
Lucio.