Interface IObservable


public interface IObservable
NOTE: This is the replacement of the deprecated Observer pattern.

As multiple inheritance is not allowed in Java, the IObservable interface allows to implement same behavior than expected from the Observable class.
Expected behavior (from Observable) :
  • The implementation represents an observable object, or "data" in the model-view paradigm. It represents an object that the application wants to have observed.
  • An observable object can have one or more observers. An observer may be any object that implements interface Observer. After an observable instance changes, an application calling the Observable's notifyObservers method causes all of its observers to be notified of the change by a call to their update method.
  • The order in which notifications will be delivered is unspecified. The default implementation provided in the Observable class will notify Observers in the order in which they registered interest, but subclasses may change this order, use no guaranteed order, deliver notifications on separate threads, or may guarantee that their subclass follows this order, as they choose.
  • Note that this notification mechanism is has nothing to do with threads and is completely separate from the wait and notify mechanism of class Object.
  • When an observable object is newly created, its set of observers is empty. Two observers are considered the same if and only if the equals method returns true for them.
Provided by the broldev.core.model project.
Since:
1.0 Jan 8, 2009, broldev.core.model 0.0.1-SNAPSHOT dependency
Version:
1.2 Jan 3, 2014
Author:
Steph GAUDRY
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    void
    Deletes an observer from the set of observers of this object.
  • Method Details

    • addObserver

      void addObserver(PropertyChangeListener pcl)
      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.
      Parameters:
      pcl - an observer to be added.
      Throws:
      NullPointerException - if the parameter o is null.
    • deleteObserver

      void deleteObserver(PropertyChangeListener pcl)
      Deletes an observer from the set of observers of this object. Passing null to this method will have no effect.
      Parameters:
      pcl - the observer to be deleted.