类 Observable
- java.lang.Object
-
- com.alibaba.nacos.common.utils.Observable
-
public class Observable extends java.lang.ObjectObservable utils.- 作者:
- liaochuntao
-
-
字段概要
字段 修饰符和类型 字段 说明 private booleanchangedprivate java.util.Set<Observer>obsprivate intobserverCnt
-
构造器概要
构造器 构造器 说明 Observable()
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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 voidclearChanged()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.intcountObservers()Returns the number of observers of thisObservableobject.voiddeleteObserver(Observer o)Deletes an observer from the set of observers of this object.voiddeleteObservers()Clears the observer list so that this object no longer has any observers.booleanhasChanged()Tests if this object has changed.voidnotifyObservers()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.protected voidsetChanged()Marks thisObservableobject as having been changed; thehasChangedmethod will now returntrue.
-
-
-
字段详细资料
-
changed
private transient boolean changed
-
obs
private transient java.util.Set<Observer> obs
-
observerCnt
private volatile int observerCnt
-
-
方法详细资料
-
addObserver
public void addObserver(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. The order in which notifications will be delivered to multiple observers is not specified. See the class comment.- 参数:
o- an observer to be added.- 抛出:
java.lang.NullPointerException- if the parameter o is null.
-
deleteObserver
public void deleteObserver(Observer o)
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.- 另请参阅:
Observable.notifyObservers(),Observable.notifyObservers(java.lang.Object)
-
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.
-
-