@BeanProperty是否具有PropertyChangeListener支持? [英] @BeanProperty with PropertyChangeListener support?

查看:67
本文介绍了@BeanProperty是否具有PropertyChangeListener支持?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

@BeanProperty生成简单的get/set方法.有没有一种方法可以自动生成此类方法,并支持触发属性更改事件(例如,我想将其与JFace Databinding一起使用?)

@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?)

推荐答案

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

这篇关于@BeanProperty是否具有PropertyChangeListener支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆