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 void
addObserver(ObserverInterfaceType observer)
Add an observer which will listen to the actions of this object.ObserverInterfaceType
getEventDispatcher()
Get the event dispatcher through which you can notify the observers.List<ObserverInterfaceType>
getObservers()
void
removeAllObserver()
void
removeObserver(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:IAbstractObservable
Add an observer which will listen to the actions of this object.- Specified by:
addObserver
in interfaceIAbstractObservable<ObserverInterfaceType>
- Parameters:
observer
- The observer which should listen to this observable.
-
removeObserver
public void removeObserver(ObserverInterfaceType observer)
Description copied from interface:IAbstractObservable
Remove an observer which was listening to this object.- Specified by:
removeObserver
in interfaceIAbstractObservable<ObserverInterfaceType>
- Parameters:
observer
- The observer to remove.
-
getObservers
public List<ObserverInterfaceType> getObservers()
-
removeAllObserver
public void removeAllObserver()
-
-