类 Observable
java.lang.Object
com.alibaba.nacos.common.utils.Observable
Observable utils.
- 作者:
- liaochuntao
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidaddObserver(Observer o)Adds an observer to the set of observers for this object, provided that it is not the same as some observer already in the set.protected voidIndicates that this object has no longer changed, or that it has already notified all of its observers of its most recent change, so that thehasChangedmethod will now returnfalse.intReturns the number of observers of thisObservableobject.voidDeletes an observer from the set of observers of this object.voidClears the observer list so that this object no longer has any observers.booleanTests if this object has changed.voidIf this object has changed, as indicated by thehasChangedmethod, then notify all of its observers and then call theclearChangedmethod to indicate that this object has no longer changed.protected voidMarks thisObservableobject as having been changed; thehasChangedmethod will now returntrue.
-
构造器详细资料
-
Observable
public Observable()
-
-
方法详细资料
-
addObserver
Adds an observer to the set of observers for this object, provided that it is not the same as some observer already in the set. The order in which notifications will be delivered to multiple observers is not specified. See the class comment.- 参数:
o- an observer to be added.- 抛出:
NullPointerException- if the parameter o is null.
-
deleteObserver
Deletes an observer from the set of observers of this object. Passingnullto this method will have no effect.- 参数:
o- the observer to be deleted.
-
notifyObservers
public void notifyObservers()If this object has changed, as indicated by thehasChangedmethod, then notify all of its observers and then call theclearChangedmethod to indicate that this object has no longer changed.Each observer has its
updatemethod called with one argument: this observable object. -
deleteObservers
public void deleteObservers()Clears the observer list so that this object no longer has any observers. -
setChanged
protected void setChanged()Marks thisObservableobject as having been changed; thehasChangedmethod will now returntrue. -
clearChanged
protected void clearChanged()Indicates that this object has no longer changed, or that it has already notified all of its observers of its most recent change, so that thehasChangedmethod will now returnfalse. This method is called automatically by thenotifyObserversmethods. -
hasChanged
public boolean hasChanged()Tests if this object has changed.- 返回:
trueif and only if thesetChangedmethod has been called more recently than theclearChangedmethod on this object;falseotherwise.
-
countObservers
public int countObservers()Returns the number of observers of thisObservableobject.- 返回:
- the number of observers of this object.
-