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 Constructor Description AbstractObservable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddObserver(ObserverInterfaceType observer)Add an observer which will listen to the actions of this object.ObserverInterfaceTypegetEventDispatcher()Get the event dispatcher through which you can notify the observers.List<ObserverInterfaceType>getObservers()voidremoveAllObserver()voidremoveObserver(ObserverInterfaceType observer)Remove an observer which was listening to this object.
-
-
-
Method Detail
-
getEventDispatcher
public ObserverInterfaceType getEventDispatcher()
Get the event dispatcher through which you can notify the observers.- Returns:
- The event dispatcher through which you can notify the observers.
-
addObserver
public void addObserver(ObserverInterfaceType observer)
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
public void removeObserver(ObserverInterfaceType observer)
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
public List<ObserverInterfaceType> getObservers()
-
removeAllObserver
public void removeAllObserver()
-
-