T
- the type to holdpublic class Observable<T> extends Object
Constructor and Description |
---|
Observable(T initialValue,
Class<T> clazz) |
Modifier and Type | Method and Description |
---|---|
void |
addCallback(IInvalidationCallback callback)
Adds a callback that is notified when
setValue is called. |
static <T> Observable<T> |
create(T initialValue)
Creates a new
Observable with the given initial value. |
static <T> Observable<T> |
create(T initialValue,
Class<T> clazz) |
T |
getValue()
Returns the observable value.
|
void |
removeCallback(IInvalidationCallback callback)
Remove the given callback.
|
void |
setValue(T value)
Sets the observable value.
|
@NotNull public static <T> Observable<T> create(T initialValue)
Observable
with the given initial value.initialValue
- the initial value.@NotNull public static <T> Observable<T> create(T initialValue, @NotNull Class<T> clazz)
public T getValue()
public void setValue(T value) throws IllegalStateException
This triggers a call to the configured
callbacks.
value
- the new valueIllegalStateException
- when calling setValue
on derived instances for example.public void addCallback(@NotNull IInvalidationCallback callback) throws IllegalArgumentException
setValue
is called.callback
- a callbackIllegalArgumentException
- when the call back is already added.public void removeCallback(@NotNull IInvalidationCallback callback) throws IllegalArgumentException
callback
- a callbackIllegalArgumentException
- when the call back is not known.