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

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

public interface ValueMap<K,V>
extends ValueProvider<K,V>, ValueAsStringProvider<K>, ValueCollectionProvider<V>

An interface describing an object mapping values to keys, null values are allowed.


Nested Class Summary
static interface ValueMap.ToString<K>
          Describes an object responsible for providing String representations of ValueMap instances
 
Method Summary
 void clear()
          Removes all values from this map.
 boolean containsValue(K key)
          Returns true if this ValueMap contains a value for the given key, that value can be null.
 V copyValue(V value)
          Returns a deep copy of the given value, immutable values are simply returned.
 Collection<K> getValueKeys()
           
 Collection<V> getValues()
          Retrieves the values associated with this value provider.
 boolean isValueNull(K key)
          Returns true if a null value is mapped to the given key.
 V removeValue(K key)
          Removes the given key and value from this value map along with the original value if any.
 V setValue(K key, V value)
          Maps the given value to the given key, returning the old value if any.
 int 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

setValue

V setValue(K key,
           V value)
Maps the given value to the given key, returning the old value if any.

Parameters:
key - the key
value - the value
Returns:
the previous value mapped to the given key, null if no such value existed

removeValue

V removeValue(K key)
Removes the given key and value from this value map along with the original value if any. If no value is mapped to the given key, this method has no effect.

Parameters:
key - the key to remove
Returns:
the value that was removed

clear

void clear()
Removes all values from this map.


isValueNull

boolean isValueNull(K key)
Returns true if a null value is mapped to the given key.

Parameters:
key - the key
Returns:
true if the value mapped to the given key is null

containsValue

boolean containsValue(K key)
Returns true if this ValueMap contains a value for the given key, that value can be null.

Parameters:
key - the key
Returns:
true if a value is mapped to this key

getValues

Collection<V> getValues()
Description copied from interface: ValueCollectionProvider
Retrieves the values associated with this value provider.

Specified by:
getValues in interface ValueCollectionProvider<V>
Returns:
an unmodifiable view of the values in this map.

getValueKeys

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

size

int size()
Returns:
the number of values in this map

copyValue

V copyValue(V value)
Returns a deep copy of the given value, immutable values are simply returned.

Parameters:
value - the value to copy
Returns:
a deep copy of the given value, or the same instance in case the value is immutable