类 Observable

java.lang.Object
com.alibaba.nacos.common.utils.Observable

public class Observable extends Object
Observable utils.
作者:
liaochuntao
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    void
    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 void
    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 the hasChanged method will now return false.
    int
    Returns the number of observers of this Observable object.
    void
    Deletes an observer from the set of observers of this object.
    void
    Clears the observer list so that this object no longer has any observers.
    boolean
    Tests if this object has changed.
    void
    If this object has changed, as indicated by the hasChanged method, then notify all of its observers and then call the clearChanged method to indicate that this object has no longer changed.
    protected void
    Marks this Observable object as having been changed; the hasChanged method will now return true.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • Observable

      public Observable()
  • 方法详细资料

    • 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.
      抛出:
      NullPointerException - if the parameter o is null.
    • deleteObserver

      public void deleteObserver(Observer o)
      Deletes an observer from the set of observers of this object. Passing null to this method will have no effect.
      参数:
      o - the observer to be deleted.
    • notifyObservers

      public void notifyObservers()
      If this object has changed, as indicated by the hasChanged method, then notify all of its observers and then call the clearChanged method to indicate that this object has no longer changed.

      Each observer has its update method 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 this Observable object as having been changed; the hasChanged method will now return true.
    • 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 the hasChanged method will now return false. This method is called automatically by the notifyObservers methods.
      另请参阅:
      Observable.notifyObservers(), Observable.notifyObservers(java.lang.Object)
    • hasChanged

      public boolean hasChanged()
      Tests if this object has changed.
      返回:
      true if and only if the setChanged method has been called more recently than the clearChanged method on this object; false otherwise.
    • countObservers

      public int countObservers()
      Returns the number of observers of this Observable object.
      返回:
      the number of observers of this object.