java 中的触发事件
为什么 PropertyChangeSupport 类中的方法 firePropertyChange (String propertyName, Object oldValue, Object newValue) 不检查旧值和新值是否可以同时为 null?
Why method firePropertyChange (String propertyName, Object oldValue, Object newValue) in class PropertyChangeSupport don't check that old and new value can be null at the same time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
PropertyChangeEvent javadoc 可能会提供一些线索:
因此,当
source==null
时,oldValue==null
和newValue==null
看起来也有一些特殊含义。因此,当两个值都为 null 时,即使它们相同,也可能希望始终传播更改。PropertyChangeEvent javadoc may give some clue about it:
So it looks like having
oldValue==null
andnewValue==null
can have some special meaning whensource==null
as well. Because of this is may want to always propagate the change when both values arenulls
even though they are the same.我不确定你的意思是什么,但这里的实际代码肯定比我试图解释的更干净:)
I am not sure what do you mean, but here is actual code that is definitelly more clean than me trying to explain it :)