T - the data type on whose changes is notifiedpublic abstract class AbstractObservable<T> extends Object implements Observable<T>
Shutdownable.ShutdownDeamon| Modifier and Type | Field and Description |
|---|---|
protected int |
latestValueHash |
protected List<Observer<T>> |
observers |
protected boolean |
unchangedValueFilter |
| Constructor and Description |
|---|
AbstractObservable()
Construct new Observable.
|
AbstractObservable(boolean unchangedValueFilter)
Construct new Observable
|
AbstractObservable(boolean unchangedValueFilter,
Object source)
Construct new Observable.
|
AbstractObservable(Object source)
Construct new Observable.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addObserver(Observer<T> observer)
Method registers the given observer to this observable to get informed about value changes.
|
protected void |
applyValueUpdate(T value)
Method is called if a observer notification delivers a new value.
|
boolean |
isNotificationInProgess()
Method checks if a notification is currently in progess.
|
boolean |
notifyObservers(Observable<T> source,
T observable)
Notify all changes of the observable to all observers only if the observable has changed.
|
boolean |
notifyObservers(T observable)
Notify all changes of the observable to all observers only if the observable has changed.
|
void |
removeObserver(Observer<T> observer)
Method removes the given observer from this observable to finish the observation.
|
void |
setExecutorService(ExecutorService executorService)
Set an executor service for the observable.
|
void |
setHashGenerator(HashGenerator<T> hashGenerator) |
void |
shutdown() |
String |
toString() |
void |
waitUntilNotificationIsFinished() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetLatestValue, getValue, getValueFuture, isValueAvailable, waitForValue, waitForValueregisterShutdownHook, registerShutdownHookprotected final boolean unchangedValueFilter
protected int latestValueHash
public AbstractObservable()
public AbstractObservable(Object source)
source - the responsible source of the value notifications.public AbstractObservable(boolean unchangedValueFilter)
unchangedValueFilter - defines if the observer should be informed even if the value is
the same than notified before.public AbstractObservable(boolean unchangedValueFilter,
Object source)
If the source is not defined the observable itself will be used as notification source.
unchangedValueFilter - defines if the observer should be informed even if the value is
the same than notified before.source - the responsible source of the value notifications.public void addObserver(Observer<T> observer)
addObserver in interface Observable<T>observer - public void removeObserver(Observer<T> observer)
removeObserver in interface Observable<T>observer - public void shutdown()
shutdown in interface Shutdownablepublic boolean notifyObservers(T observable) throws MultiException, CouldNotPerformException
observable - the value which is notifiedMultiException - thrown if the notification to at least one observer failsCouldNotPerformException - thrown if the hash computation failspublic boolean notifyObservers(Observable<T> source, T observable) throws MultiException, CouldNotPerformException
Note: In case the given observable is null this notification will be ignored.
source - the source of the notificationobservable - the value which is notifiedMultiException - thrown if the notification to at least one observer failsCouldNotPerformException - thrown if the hash computation failsprotected void applyValueUpdate(T value) throws NotAvailableException
value - the new value
Note: Overwrite this method for getting informed about value changes.
NotAvailableExceptionpublic void setExecutorService(ExecutorService executorService)
executorService - the executor service which will be used for parallelizationpublic void setHashGenerator(HashGenerator<T> hashGenerator)
public boolean isNotificationInProgess()
public void waitUntilNotificationIsFinished()
throws InterruptedException
InterruptedExceptionCopyright © 2015–2018 openbase.org. All rights reserved.