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
ConstructorDescriptionSingleEntryMap
(K key) Create empty mapSingleEntryMap
(K key, V value) Create map with single key-value entry -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
computeIfAbsent
(K key, Function<? super K, ? extends V> mappingFunction) computeIfPresent
(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
boolean
void
forEach
(BiConsumer<? super K, ? super V> action) getKey()
getOrDefault
(Object key, V defaultValue) getValue()
int
hashCode()
boolean
isEmpty()
keySet()
void
putIfAbsent
(K key, V value) boolean
boolean
int
size()
toString()
values()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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:
containsKey
in interfaceMap<K,
V>
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsValue
- Specified by:
containsValue
in 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:
getOrDefault
in interfaceMap<K,
V>
-
putIfAbsent
- Specified by:
putIfAbsent
in interfaceMap<K,
V>
-
computeIfAbsent
- Specified by:
computeIfAbsent
in interfaceMap<K,
V>
-
computeIfPresent
- Specified by:
computeIfPresent
in interfaceMap<K,
V>
-
compute
-
merge
-
replace
-
replace
-
remove
-