@BeanProperty 具有 PropertyChangeListener 支持吗?
@BeanProperty
生成简单的 get
/set
方法。有没有一种方法可以自动生成此类方法并支持触发属性更改事件(例如,我想将其与 JFace 数据绑定一起使用?)
@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?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也有同样的问题,并一直在密切关注可能的答案。我想我刚刚偶然发现了一个(尽管我还没有尝试过)。 Scala 2.9 有一个处理动态调用的功能(我怀疑是为了与动态语言集成)。本质上,对不存在的方法的调用将被路由到名为 applyDynamic 的方法。该方法的实现可以使用反射来检查方法签名是否与属性匹配(可能具有类似于 @BeanProperty 的注释)。如果存在匹配,它可以处理触发事件。
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.
也许这就是自定义编译器插件可以解决的问题。
可悲的是我不知道如何编写这样的插件。但至少我想我给了你这个指示。
如果您能提出类似的想法,我会非常感兴趣。
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.