@BeanProperty 具有 PropertyChangeListener 支持吗?

发布于 2024-09-02 03:21:05 字数 131 浏览 4 评论 0原文

@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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ま柒月 2024-09-09 03:21:05

我也有同样的问题,并一直在密切关注可能的答案。我想我刚刚偶然发现了一个(尽管我还没有尝试过)。 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.

一指流沙 2024-09-09 03:21:05

也许这就是自定义编译器插件可以解决的问题。
可悲的是我不知道如何编写这样的插件。但至少我想我给了你这个指示。

如果您能提出类似的想法,我会非常感兴趣。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文