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>
public class SingleEntryMap<K,V> extends Object implements Map<K,V>, Map.Entry<K,V>, Serializable
Optimized mutable single-entry map.This implementation is compatible with general
Mapcontract, includingMap.equals(Object),Map.hashCode()andAbstractMap.toString()implementations.This Map can store only one key that is defined at creation time and can't be changed. This map will throw
IllegalArgumentExceptionon any put operation with the wrong key and returnnullon get.This map will be effectively empty after putting null value.
- Since:
- 4.2
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SingleEntryMap(K key)Create empty mapSingleEntryMap(K key, V value)Create map with single key-value entry
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Vcompute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)VcomputeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)VcomputeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<K,V>>entrySet()booleanequals(Object o)voidforEach(BiConsumer<? super K,? super V> action)Vget(Object key)KgetKey()VgetOrDefault(Object key, V defaultValue)VgetValue()inthashCode()booleanisEmpty()Set<K>keySet()Vmerge(K key, V newValue, BiFunction<? super V,? super V,? extends V> remappingFunction)Vput(K key, V value)voidputAll(Map<? extends K,? extends V> map)VputIfAbsent(K key, V value)Vremove(Object key)booleanremove(Object key, Object value)Vreplace(K key, V value)booleanreplace(K key, V oldValue, V newValue)VsetValue(V value)intsize()StringtoString()Collection<V>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 Detail
-
SingleEntryMap
public SingleEntryMap(K key)
Create empty map- Parameters:
key- that can be stored in this map, can't be null
-
-
Method Detail
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<K,V>
-
equals
public boolean equals(Object o)
-
hashCode
public int hashCode()
-
forEach
public void forEach(BiConsumer<? super K,? super V> action)
-
getOrDefault
public V getOrDefault(Object key, V defaultValue)
- Specified by:
getOrDefaultin interfaceMap<K,V>
-
computeIfAbsent
public V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
- Specified by:
computeIfAbsentin interfaceMap<K,V>
-
computeIfPresent
public V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
- Specified by:
computeIfPresentin interfaceMap<K,V>
-
merge
public V merge(K key, V newValue, BiFunction<? super V,? super V,? extends V> remappingFunction)
-
-