public class SingleEntryMap<K,V> extends Object implements Map<K,V>, Map.Entry<K,V>, Serializable
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.
| Constructor and Description |
|---|
SingleEntryMap(K key)
Create empty map
|
SingleEntryMap(K key,
V value)
Create map with single key-value entry
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
V |
compute(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction) |
V |
computeIfAbsent(K key,
Function<? super K,? extends V> mappingFunction) |
V |
computeIfPresent(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction) |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Set<Map.Entry<K,V>> |
entrySet() |
boolean |
equals(Object o) |
void |
forEach(BiConsumer<? super K,? super V> action) |
V |
get(Object key) |
K |
getKey() |
V |
getOrDefault(Object key,
V defaultValue) |
V |
getValue() |
int |
hashCode() |
boolean |
isEmpty() |
Set<K> |
keySet() |
V |
merge(K key,
V newValue,
BiFunction<? super V,? super V,? extends V> remappingFunction) |
V |
put(K key,
V value) |
void |
putAll(Map<? extends K,? extends V> map) |
V |
putIfAbsent(K key,
V value) |
V |
remove(Object key) |
boolean |
remove(Object key,
Object value) |
V |
replace(K key,
V value) |
boolean |
replace(K key,
V oldValue,
V newValue) |
V |
setValue(V value) |
int |
size() |
String |
toString() |
Collection<V> |
values() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitreplaceAllcomparingByKey, comparingByKey, comparingByValue, comparingByValuepublic SingleEntryMap(K key)
key - that can be stored in this map, can't be nullpublic boolean containsKey(Object key)
containsKey in interface Map<K,V>public boolean containsValue(Object value)
containsValue in interface Map<K,V>public boolean equals(Object o)
public int hashCode()
public void forEach(BiConsumer<? super K,? super V> action)
public V getOrDefault(Object key, V defaultValue)
getOrDefault in interface Map<K,V>public V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
computeIfAbsent in interface Map<K,V>public V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
computeIfPresent in interface Map<K,V>public V merge(K key, V newValue, BiFunction<? super V,? super V,? extends V> remappingFunction)
Copyright © 2001–2021 Apache Cayenne. All rights reserved.