public class Value<T> extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Value.Listener<T>
Used to hear about changes to the value.
|
| Constructor and Description |
|---|
Value(T init)
Creates a new value with the specified initial value.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(Value.Listener<T> listener)
Adds a listener which will subsequently be notified when this value changes.
|
void |
addListenerAndTrigger(Value.Listener<T> listener)
Adds a listener and immediately triggers it with our current value.
|
static <T> Value<T> |
create(T value)
Creates a new value with the specified initial value.
|
T |
get()
Returns the current value.
|
<M> Value<M> |
map(Function<T,M> func)
Creates a value that maps this value via a function.
|
void |
removeListener(Value.Listener<T> listener)
Removes a listener from this value.
|
void |
update(T value)
Updates this value and notifies all listeners.
|
void |
updateIf(T value)
Updates this value and notifies all listeners if the supplied value differs from the current
value (via the
Object.equals(java.lang.Object) contract). |
public Value(T init)
public static <T> Value<T> create(T value)
public void addListener(Value.Listener<T> listener)
public void addListenerAndTrigger(Value.Listener<T> listener)
public void removeListener(Value.Listener<T> listener)
public T get()
public void update(T value)
public void updateIf(T value)
Object.equals(java.lang.Object) contract).public <M> Value<M> map(Function<T,M> func)
update(T).Copyright © 2013. All Rights Reserved.