Interface IObservable

  • All Known Implementing Classes:
    BaseObservable, Pipeline, WeakReferenceObservable, XPipeline

    public interface IObservable
    This interface is intended to provide more flexibility to complex object models when multiple inheritance is needed.

    By providing Observable as an interface, instead of the JDK'a Observable class, client classes have the option to mimic multiple inheritance by means of a delegate pattern which uses an inner private class which implements this interface.

    This class is based on the work done by Martin Fischer, with only minor changes. See references below.

    Author:
    Martin Fischer (original author), Richard Gomes
    See Also:
    Martin Fischer: Observer and Observable interfaces, Improved Observer/Observable
    • Method Detail

      • addObserver

        void addObserver​(IObserver observer)
        Attaches a observer to the Observable. After attachment the observer gets informed about changes in the Observable.
        Parameters:
        observer - The observer to attach to the observable
      • countObservers

        int countObservers()
        Counts how many Observers were attached to this class.
        Returns:
        the number of Observers
        See Also:
        IObserver
      • getObservers

        List<IObserver> getObservers()
        Returns list of observers registered with the Observable. List returned is unmodifiable list.
        Returns:
        list of observers
      • deleteObserver

        void deleteObserver​(IObserver observer)
        Detaches a previously attached observer to the observable. After detachment the observer does no longer receive change notifications from the observable.
        Parameters:
        observer - The observer to detach from the observable
      • deleteObservers

        void deleteObservers()
        Detaches all previously attached observer to the observable. After detachment observers do not longer receive change notifications from the observable.
      • notifyObservers

        void notifyObservers()
        Notifies all attached observers about changes in the observable.
      • notifyObservers

        void notifyObservers​(Object arg)
        Notifies all attached observers about changes in the observable.
        Parameters:
        arg - an arbitrary Object to be passed to the Observer