@BeanProperty with PropertyChangeListener support?

筅森魡賤 提交于 2020-01-02 05:05:09

问题


@BeanProperty generates simple get/set methods. Is there a way to automatically generate such methods with support for firing property change events (e.g. I want to use it with JFace Databinding?)


回答1:


I've had the same question, and have been keeping a close eye out for possible answers. I think I've just stumbled across one (although I haven't tried it yet). Scala 2.9 has a feature for handling dynamic calls (meant for integration with dynamic languages, I suspect). Essentially, calls to methods which don't exist are routed to a method called applyDynamic. An implementation of that method could use reflection to check that the method signature matches a property (possibly one with an annotation similar to @BeanProperty). If there is a match, it could handle firing the event.




回答2:


Maybe that's something where a custom compiler plugin can do the trick. Sadly I have no idea about how to write such a plugin. But at least thought I give you this pointer.

I would be very interested, if you'd come up with something along that line.



来源:https://stackoverflow.com/questions/2856299/beanproperty-with-propertychangelistener-support

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!