Class AbstractObservable<ObserverInterfaceType>
java.lang.Object
org.palladiosimulator.commons.designpatterns.AbstractObservable<ObserverInterfaceType>
- Type Parameters:
ObserverInterfaceType- The interface which should be implemented by the observers.
- All Implemented Interfaces:
IAbstractObservable<ObserverInterfaceType>
public abstract class AbstractObservable<ObserverInterfaceType>
extends Object
implements IAbstractObservable<ObserverInterfaceType>
A generic implementation of an Observable object as defined by the Observer pattern. As a type parameter
the interface for the Observer needs to be specified.
Taken from http://pastebin.com/YmVhDNzk and adapted
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddObserver(ObserverInterfaceType observer) Add an observer which will listen to the actions of this object.Get the event dispatcher through which you can notify the observers.voidvoidremoveObserver(ObserverInterfaceType observer) Remove an observer which was listening to this object.
-
Constructor Details
-
AbstractObservable
public AbstractObservable()
-
-
Method Details
-
getEventDispatcher
Get the event dispatcher through which you can notify the observers.- Returns:
- The event dispatcher through which you can notify the observers.
-
addObserver
Description copied from interface:IAbstractObservableAdd an observer which will listen to the actions of this object.- Specified by:
addObserverin interfaceIAbstractObservable<ObserverInterfaceType>- Parameters:
observer- The observer which should listen to this observable.
-
removeObserver
Description copied from interface:IAbstractObservableRemove an observer which was listening to this object.- Specified by:
removeObserverin interfaceIAbstractObservable<ObserverInterfaceType>- Parameters:
observer- The observer to remove.
-
getObservers
-
removeAllObserver
public void removeAllObserver()
-