public abstract class Observable<T> extends Object
ArrayList
.
This abstract class is intended to be subclassed and specialized to maintain
a registry of observers of specific types and dispatch notifications to them.Modifier and Type | Field and Description |
---|---|
protected ArrayList<T> |
mObservers
The list of observers.
|
Constructor and Description |
---|
Observable() |
Modifier and Type | Method and Description |
---|---|
void |
registerObserver(T observer)
Adds an observer to the list.
|
void |
unregisterAll()
Remove all registered observers.
|
void |
unregisterObserver(T observer)
Removes a previously registered observer.
|
public void registerObserver(T observer)
observer
- the observer to registerIllegalArgumentException
- the observer is nullIllegalStateException
- the observer is already registeredpublic void unregisterObserver(T observer)
observer
- the observer to unregisterIllegalArgumentException
- the observer is nullIllegalStateException
- the observer is not yet registeredpublic void unregisterAll()