Package com.luciad.utils
Class Observable<T>
java.lang.Object
com.luciad.utils.Observable<T>
This class makes it possible to hold and observe a value that can change over time.
-
Constructor Summary
ConstructorsConstructorDescriptionObservable(T initialValue) Constructs the observable with an initial value.Observable(T initialValue, Class<T> clazz) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCallback(IInvalidationCallback callback) Adds a callback that is notified whensetValueis called.static <T> Observable<T> create(T initialValue) Creates a newObservablewith the given initial value.static <T> Observable<T> getValue()Returns the observable value.voidremoveCallback(IInvalidationCallback callback) Remove the given callback.voidSets the observable value.
-
Constructor Details
-
Observable
Constructs the observable with an initial value.- Parameters:
initialValue- the initial value.
-
Observable
-
-
Method Details
-
create
Creates a newObservablewith the given initial value.- Parameters:
initialValue- the initial value.
-
create
-
getValue
Returns the observable value.- Returns:
- the observable value.
-
setValue
Sets the observable value.This triggers a call to the
configuredcallbacks.- Parameters:
value- the new value- Throws:
IllegalStateException- when callingsetValueon derived instances for example.
-
addCallback
Adds a callback that is notified whensetValueis called.- Parameters:
callback- a callback- Throws:
IllegalArgumentException- when the call back is already added.
-
removeCallback
Remove the given callback.- Parameters:
callback- a callback- Throws:
IllegalArgumentException- when the call back is not known.
-