Package com.randomnoun.common
Class HashMapIgnoreCase<K,V>
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<String,
V>
Case-preserving hashmap that allows case-insensitive lookups.
- Author:
- knoxg
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,
V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(Object key) Returns true if this map contains a mapping for the specified key.Retrieve a value from the cache.Associates the specified value with the specified key in this map.Removes the mapping for this key from this map if present.Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsValue, entrySet, forEach, getOrDefault, isEmpty, keySet, merge, newHashMap, putAll, putIfAbsent, remove, replace, replace, replaceAll, size, values
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Constructor Details
-
HashMapIgnoreCase
public HashMapIgnoreCase()
-
-
Method Details
-
get
Retrieve a value from the cache. -
put
Associates the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced.- Specified by:
put
in interfaceMap<K,
V> - Overrides:
put
in classHashMap<String,
V> - Parameters:
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.- Returns:
- previous value associated with specified key, or
null
if there was no mapping for key. Anull
return can also indicate that the HashMap previously associatednull
with the specified key. - Throws:
IllegalArgumentException
- if the key parameter is not a String
-
containsKey
Returns true if this map contains a mapping for the specified key. More formally, returns true if and only if this map contains at a mapping for a keyk
such that (key==null ? k==null : key.equals(k)
). (There can be at most one such mapping.)- Specified by:
containsKey
in interfaceMap<K,
V> - Overrides:
containsKey
in classHashMap<String,
V> - Parameters:
key
- key whose presence in this map is to be tested.- Returns:
- true if this map contains a mapping for the specified key.
-
remove
Removes the mapping for this key from this map if present.- Specified by:
remove
in interfaceMap<K,
V> - Overrides:
remove
in classHashMap<String,
V> - Parameters:
key
- key whose mapping is to be removed from the map.- Returns:
- previous value associated with specified key, or
null
if there was no mapping for key. Anull
return can also indicate that the map previously associatednull
with the specified key.
-