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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addObserver
(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.void
void
removeObserver
(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: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
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
-
removeAllObserver
public void removeAllObserver()
-