Package org.apache.cayenne.util
Class SingleEntryMap<K,V>
java.lang.Object
org.apache.cayenne.util.SingleEntryMap<K,V>
- All Implemented Interfaces:
Serializable,Map<K,,V> Map.Entry<K,V>
Optimized mutable single-entry map.
This implementation is compatible with general Map contract, including Map.equals(Object),
Map.hashCode() and AbstractMap.toString() implementations.
This Map can store only one key that is defined at creation time and can't be changed.
This map will throw IllegalArgumentException on any put operation with the wrong key
and return null on get.
This map will be effectively empty after putting null value.
- Since:
- 4.2
- See Also:
-
Nested Class Summary
-
Constructor Summary
ConstructorsConstructorDescriptionSingleEntryMap(K key) Create empty mapSingleEntryMap(K key, V value) Create map with single key-value entry -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()booleanvoidforEach(BiConsumer<? super K, ? super V> action) getKey()getOrDefault(Object key, V defaultValue) getValue()inthashCode()booleanisEmpty()keySet()voidputIfAbsent(K key, V value) booleanbooleanintsize()toString()values()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
replaceAll
-
Constructor Details
-
SingleEntryMap
Create empty map- Parameters:
key- that can be stored in this map, can't be null
-
SingleEntryMap
Create map with single key-value entry- Parameters:
key- that can be stored in this map, can't be nullvalue- to store, if null map will be empty.
-
-
Method Details
-
entrySet
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsValue
- Specified by:
containsValuein interfaceMap<K,V>
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-
getKey
-
getValue
-
setValue
-
equals
-
hashCode
public int hashCode() -
toString
-
forEach
-
getOrDefault
- Specified by:
getOrDefaultin interfaceMap<K,V>
-
putIfAbsent
- Specified by:
putIfAbsentin interfaceMap<K,V>
-
computeIfAbsent
- Specified by:
computeIfAbsentin interfaceMap<K,V>
-
computeIfPresent
- Specified by:
computeIfPresentin interfaceMap<K,V>
-
compute
-
merge
-
replace
-
replace
-
remove
-