K
- the type of the map keysV
- the type of the map valuespublic interface ValueMap<K,V> extends ValueProvider<K,V>, ValueCollectionProvider<V>
getOriginal(Object)
returns that original value and
isModified(Object)
returns true until the value is either saved via
save(Object)
or reverted to its original value via revert(Object)
,
note that setting the original value manually has the same effect as calling revert(Object)
Modifier and Type | Interface and Description |
---|---|
static interface |
ValueMap.Validator<K,V extends ValueMap<K,?>>
A validator for ValueMaps
|
Modifier and Type | Method and Description |
---|---|
void |
addValueListener(EventDataListener<ValueChange<K,V>> valueListener)
Adds a listener notified each time a value changes
Adding the same listener multiple times has no effect.
|
void |
clear()
Silently removes all values from this map, as in, removes the values
without firing value change events
|
boolean |
containsKey(K key)
Returns true if this ValueMap contains a value for the given key, that value can be null.
|
java.lang.String |
getAsString(K key)
Retrieves a string representation of the value mapped to the given key, an empty string is returned
in case of null values or if key is not found.
|
ValueMap<K,V> |
getCopy() |
StateObserver |
getModifiedObserver() |
V |
getOriginal(K key)
Returns the original value associated with the given key or the current value if it has not been modified.
|
ValueMap<K,V> |
getOriginalCopy() |
EventObserver<ValueChange<K,V>> |
getValueObserver()
Returns an EventObserver notified each time a value changes, with a
ValueChange argument. |
boolean |
isModified() |
boolean |
isModified(K key)
Returns true if the value associated with the given key has been modified..
|
boolean |
isNotNull(K key)
Returns true if a this ValueMap contains a non-null value mapped to the given key
|
boolean |
isNull(K key)
Returns true if a null value is mapped to the given key or the key is not found.
|
java.util.Set<K> |
keySet() |
ValueMap<K,V> |
newInstance() |
java.util.Set<K> |
originalKeySet() |
V |
put(K key,
V value)
Maps the given value to the given key, returning the old value if any.
|
V |
remove(K key)
Removes the given key and value from this value map along with the original value if any.
|
void |
removeValueListener(EventDataListener valueListener)
Removes the given value listener if it has been registered with this value map.
|
void |
revert(K key)
Reverts the value associated with the given key to its original value.
|
void |
revertAll()
Reverts all value modifications that have been made.
|
void |
save(K key)
Saves the value associated with the given key, that is, removes the original value.
|
void |
saveAll()
Saves all the value modifications that have been made.
|
void |
setAs(ValueMap<K,V> sourceMap)
After a call to this method this ValueMap contains the same values and original values as the source map.
|
int |
size() |
get
values
V put(K key, V value)
key
- the keyvalue
- the valueV remove(K key)
key
- the key to removejava.lang.String getAsString(K key)
key
- the keyvoid clear()
void setAs(ValueMap<K,V> sourceMap)
sourceMap
- the map to copy or null for clearing the destination mapboolean isNull(K key)
key
- the keyboolean isNotNull(K key)
key
- the keyboolean containsKey(K key)
key
- the keyjava.util.Set<K> keySet()
java.util.Set<K> originalKeySet()
int size()
V getOriginal(K key)
key
- the key for which to retrieve the original valueboolean isModified()
boolean isModified(K key)
key
- the keyvoid revert(K key)
key
- the key for which to revert the valuevoid revertAll()
void save(K key)
key
- the key for which to save the valuevoid saveAll()
ValueMap<K,V> getOriginalCopy()
ValueMap<K,V> newInstance()
StateObserver getModifiedObserver()
EventObserver<ValueChange<K,V>> getValueObserver()
ValueChange
argument.ValueChange
void addValueListener(EventDataListener<ValueChange<K,V>> valueListener)
valueListener
- the listenerValueChange
void removeValueListener(EventDataListener valueListener)
valueListener
- the listener to remove