Class CrudMap<Key,Value>
java.lang.Object
java.util.AbstractMap<Key,Value>
de.xima.fc.common.collection.CrudMap<Key,Value>
- Type Parameters:
Key- Type of the map keys.Value- Type of the map values.
- All Implemented Interfaces:
Serializable, Map<Key,Value>
CRUD = create, read, update, and delete
A map that delegates to a CrudMapAdapter with a get(key), set(key, value), and
delete method. This lets you implement a map in terms of simple get, set, delete operations (instead of
having to implement an entry set when using AbstractMap).
This is especially useful when you do not have a simple map, but need to compute the keys or values in some fashion.
You can also use this to implement a view of an existing map with mapped or filtered keys and values: Keys for
which get returns null are excluded from the map.
The map is serializable if the data adapter is serializable.
- Since:
- 8.2.0
- Author:
- XIMA MEDIA GmbH
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(Object key) entrySet()getOrDefault(Object key, Value defaultValue) booleanisEmpty()static <K,V> Map <K, V> newMap(Class<K> keyType, CrudMapAdapter<K, V> dataAdapter) Creates a new map that delegates to the givendata adapterfor getting data from the map, setting data to the map, and deleting data from the map.static <T> Set<T> newSet(Class<T> keyType, CrudMapAdapter<T, Unit> dataAdapter) Creates a new set that delegates to the givendata adapterfor getting elements from the set, adding deleting elements to the set, and deleting elements from the set.intsize()Methods inherited from class AbstractMap
clear, clone, containsValue, equals, hashCode, keySet, putAll, toString, valuesMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, forEach, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Method Details
-
containsKey
- Specified by:
containsKeyin interfaceMap<Key,Value> - Overrides:
containsKeyin classAbstractMap<Key,Value>
-
entrySet
-
get
-
getOrDefault
-
isEmpty
-
put
-
remove
-
size
-
newMap
Creates a new map that delegates to the givendata adapterfor getting data from the map, setting data to the map, and deleting data from the map.- Type Parameters:
K- Type of the map keys.V- Type of the map values.- Parameters:
keyType- Type of the map keys.dataAdapter- Data adapter for reading and writing data.- Returns:
- The new map.
-
newSet
Creates a new set that delegates to the givendata adapterfor getting elements from the set, adding deleting elements to the set, and deleting elements from the set.- Type Parameters:
T- Type of the set elements.- Parameters:
keyType- Type of the set elements.dataAdapter- Data adapter for reading and writing data.- Returns:
- The new set.
- See Also:
-