I work with BeanBinding a lot in my current project, and so I have code that looks like ...
TypeA objA; TypeB objB; Bindings.createAutoBinding(UpdateStrategy.READ, objA, BeanProperty.create("X"), objB, BeanProperty.create("X")) .bind();
Where objA and objB are instances of classes that have a setX() method. The problem is that if I reorganize setX into setY , then I need to track down these string property names. I understand that I can create static end lines for the property name, but if I can get the compiler to do the work for me, all the better.
Ideally, I would like to be able to ...
TypeA obja; TypeB objB; Bindings.createAutoBinding(UpdateStrategy.READ, objA, BeanProperty.create( Magic.returnBeanName(TypeA.class).getX() ), objB, BeanProperty.create( Magic.returnBeanName(TypeB.class).setX() ) .bind();
It would seem that this may be possible through some code synthesis and / or aspects.
source share