org.jminor.common.model.valuemap
Interface ValueChangeMap<K,V>

Type Parameters:
K - the type of the keys in the map
V - the type of the values in the map
All Superinterfaces:
ValueAsStringProvider<K>, ValueCollectionProvider<V>, ValueMap<K,V>, ValueProvider<K,V>
All Known Subinterfaces:
Entity
All Known Implementing Classes:
ValueChangeMapImpl

public interface ValueChangeMap<K,V>
extends ValueMap<K,V>

A ValueMap extension which keeps track of value modifications.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jminor.common.model.valuemap.ValueMap
ValueMap.ToString<K>
 
Method Summary
 void addValueListener(ActionListener valueListener)
          Adds a ActionListener, this listener will be notified each time a value changes, by calling actionPerformed() with a ValueChangeEvent argument.
 ValueChangeMap<K,V> getCopy()
           
 ValueChangeMap<K,V> getInstance()
           
 StateObserver getModifiedState()
           
 ValueChangeMap<K,V> getOriginalCopy()
           
 V getOriginalValue(K key)
          Returns the original value associated with the given key or the current value if it has not been changed.
 Collection<K> getOriginalValueKeys()
           
 EventObserver getValueChangeObserver()
          Returns an Event fired each time a value changes, with a ValueChangeEvent argument.
 void initializeValue(K key, V value)
          Initializes the value associated with the given key.
 boolean isModified()
           
 boolean isModified(K key)
          Returns true if the value associated with the given key has been modified..
 void removeValueListener(ActionListener valueListener)
          Removes the given value listener if it has been registered with this value map.
 void revertAll()
          Reverts all value changes that have been made.
 void revertValue(K key)
          Reverts the value associated with the given key to its original value.
 void saveAll()
          Saves all the value changes that have been made.
 void saveValue(K key)
          Saves the value associated with the given key, that is, removes the original value.
 void setAs(ValueChangeMap<K,V> sourceMap)
          After a call to this method this ValueChangeMap contains the same values and original values as the given map.
 
Methods inherited from interface org.jminor.common.model.valuemap.ValueMap
clear, containsValue, copyValue, getValueKeys, getValues, isValueNull, removeValue, setValue, size
 
Methods inherited from interface org.jminor.common.model.valuemap.ValueProvider
getValue
 
Methods inherited from interface org.jminor.common.model.valuemap.ValueAsStringProvider
getValueAsString
 

Method Detail

getModifiedState

StateObserver getModifiedState()
Returns:
a State active when this value map has been modified.

getValueChangeObserver

EventObserver getValueChangeObserver()
Returns an Event fired each time a value changes, with a ValueChangeEvent argument.

Returns:
an Event fired when a value changes.
See Also:
ValueChangeEvent

addValueListener

void addValueListener(ActionListener valueListener)
Adds a ActionListener, this listener will be notified each time a value changes, by calling actionPerformed() with a ValueChangeEvent argument. Adding the same listener multiple times has no effect.

Parameters:
valueListener - the ActionListener
See Also:
ValueChangeEvent

removeValueListener

void removeValueListener(ActionListener valueListener)
Removes the given value listener if it has been registered with this value map.

Parameters:
valueListener - the ActionListener to remove

initializeValue

void initializeValue(K key,
                     V value)
Initializes the value associated with the given key. This method assumes no value has been associated with the key prior to this call, use with care.

Parameters:
key - the key with which to associate the given value
value - the value to associate with the given key

getOriginalValue

V getOriginalValue(K key)
Returns the original value associated with the given key or the current value if it has not been changed.

Parameters:
key - the key for which to retrieve the original value
Returns:
the original value

isModified

boolean isModified()
Returns:
true if a value has been modified.

isModified

boolean isModified(K key)
Returns true if the value associated with the given key has been modified..

Parameters:
key - the key
Returns:
true if the value has changed

revertValue

void revertValue(K key)
Reverts the value associated with the given key to its original value. If the value has not been changed then calling this method has no effect.

Parameters:
key - the key for which to revert the value

revertAll

void revertAll()
Reverts all value changes that have been made. This value map will be unmodified after a call to this method. If no changes have been made then calling this method has no effect.


saveValue

void saveValue(K key)
Saves the value associated with the given key, that is, removes the original value. If no original value exists calling this method has no effect.

Parameters:
key - the key for which to save the value

saveAll

void saveAll()
Saves all the value changes that have been made. This value map will be unmodified after a call to this method.


getOriginalCopy

ValueChangeMap<K,V> getOriginalCopy()
Returns:
a deep copy of this value map in it's original state

getOriginalValueKeys

Collection<K> getOriginalValueKeys()
Returns:
an unmodifiable view of the keys mapping the original values in this ValueChangeMap

getInstance

ValueChangeMap<K,V> getInstance()
Returns:
a new ValueChangeMap instance compatible with this instance

getCopy

ValueChangeMap<K,V> getCopy()
Returns:
a deep copy of this value map

setAs

void setAs(ValueChangeMap<K,V> sourceMap)
After a call to this method this ValueChangeMap contains the same values and original values as the given map. A null argument to this method clears the destination map of all values and original values.

Parameters:
sourceMap - the map to copy or null for clearing the destination map