Package io.github.connellite.collections
Class NullSkippingHashMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
io.github.connellite.collections.NullSkippingHashMap<K,V>
- All Implemented Interfaces:
Serializable,Cloneable,Map<K,V>
HashMap that ignores put / putAll / putIfAbsent / merge when the key is null (no-op; null values are still stored).- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
ConstructorsConstructorDescriptionNullSkippingHashMap(int initialCapacity) NullSkippingHashMap(int initialCapacity, float loadFactor) NullSkippingHashMap(Map<? extends K, ? extends V> m) -
Method Summary
Modifier and TypeMethodDescriptionMerges value for a non-null key.Associates value with a non-null key.voidCopies all entries with non-null keys from the input map.putIfAbsent(K key, V value) Stores value for a non-null key only when absent.Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, remove, remove, replace, replace, replaceAll, size, valuesMethods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Constructor Details
-
NullSkippingHashMap
public NullSkippingHashMap() -
NullSkippingHashMap
public NullSkippingHashMap(int initialCapacity) -
NullSkippingHashMap
public NullSkippingHashMap(int initialCapacity, float loadFactor) -
NullSkippingHashMap
-
-
Method Details
-
put
Associates value with a non-null key. -
putAll
Copies all entries with non-null keys from the input map. -
putIfAbsent
Stores value for a non-null key only when absent.- Specified by:
putIfAbsentin interfaceMap<K,V> - Overrides:
putIfAbsentin classHashMap<K,V> - Parameters:
key- map keyvalue- map value- Returns:
- existing value or
null
-
merge
Merges value for a non-null key.
-