Package io.github.connellite.collections
Class NullSkippingLinkedHashMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<K,V>
io.github.connellite.collections.NullSkippingLinkedHashMap<K,V>
- All Implemented Interfaces:
Serializable,Cloneable,Map<K,V>
LinkedHashMap 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
ConstructorsConstructorDescriptionNullSkippingLinkedHashMap(int initialCapacity) NullSkippingLinkedHashMap(int initialCapacity, float loadFactor) NullSkippingLinkedHashMap(int initialCapacity, float loadFactor, boolean accessOrder) NullSkippingLinkedHashMap(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.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, valuesMethods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, remove, remove, replace, replace, sizeMethods inherited from class java.util.AbstractMap
equals, hashCode, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, remove, remove, replace, replace, size
-
Constructor Details
-
NullSkippingLinkedHashMap
public NullSkippingLinkedHashMap() -
NullSkippingLinkedHashMap
public NullSkippingLinkedHashMap(int initialCapacity) -
NullSkippingLinkedHashMap
public NullSkippingLinkedHashMap(int initialCapacity, float loadFactor) -
NullSkippingLinkedHashMap
public NullSkippingLinkedHashMap(int initialCapacity, float loadFactor, boolean accessOrder) -
NullSkippingLinkedHashMap
-
-
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.
-