T - the data type on whose changes is notifiedpublic class ObservableImpl<T> extends AbstractObservable<T>
Shutdownable.ShutdownDeamon| Modifier and Type | Field and Description |
|---|---|
protected Object |
VALUE_LOCK |
latestValueHash, observers, unchangedValueFilter| Constructor and Description |
|---|
ObservableImpl() |
ObservableImpl(boolean unchangedValueFilter) |
ObservableImpl(boolean unchangedValueFilter,
Object source) |
ObservableImpl(Object source) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
applyValueUpdate(T value)
Method is called if a observer notification delivers a new value.
|
T |
getValue()
Method returns the latest observable value.
|
CompletableFuture<T> |
getValueFuture()
Method returns a Future object which represents the value availability.
|
boolean |
isValueAvailable()
Checks if a value was ever notified.
|
void |
waitForValue(long timeout,
TimeUnit timeUnit)
Method blocks until the observable is available.
|
addObserver, isNotificationInProgess, notifyObservers, notifyObservers, removeObserver, setExecutorService, setHashGenerator, shutdown, toString, waitUntilNotificationIsFinishedclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetLatestValue, waitForValueregisterShutdownHook, registerShutdownHookprotected final Object VALUE_LOCK
public ObservableImpl()
public ObservableImpl(Object source)
source - public ObservableImpl(boolean unchangedValueFilter)
unchangedValueFilter - public ObservableImpl(boolean unchangedValueFilter,
Object source)
unchangedValueFilter - source - public void waitForValue(long timeout,
TimeUnit timeUnit)
throws CouldNotPerformException,
InterruptedException
timeout - is the timeout related to the given TimeUnit.timeUnit - is the unit of the timeout.InterruptedException - is thrown if the current thread was interrupted externally.CouldNotPerformException - is thrown with a TimeoutException cause if the given timeout
is reached.public T getValue() throws NotAvailableException
NotAvailableExceptionpublic CompletableFuture<T> getValueFuture()
public boolean isValueAvailable()
protected void applyValueUpdate(T value) throws NotAvailableException
applyValueUpdate in class AbstractObservable<T>value - the new value
Note: Overwrite this method for getting informed about value changes.
NotAvailableExceptionCopyright © 2015–2018 openbase.org. All rights reserved.