gpt4 book ai didi

java - java中的触发事件

转载 作者:行者123 更新时间:2023-11-29 09:18:08 25 4
gpt4 key购买 nike

为什么类 PropertyChangeSupport 中的方法 firePropertyChange (String propertyName, Object oldValue, Object newValue) 不检查旧值和新值是否可以同时为 null?

最佳答案

PropertyChangeEvent javadoc可能会提供一些线索:

Null values may be provided for the old and the new values if their true values are not known.

An event source may send a null object as the name to indicate that an arbitrary set of if its properties have changed. In this case the old and new values should also be null.

所以看起来 oldValue==nullnewValue==nullsource==null 时也有一些特殊的含义.因此,当两个值都为 null 时,可能希望始终传播更改,即使它们相同也是如此。

关于java - java中的触发事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8192832/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com