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 TypeMethodDescriptionbooleancontainsKey(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, valuesMethods 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:
putin interfaceMap<K,V> - Overrides:
putin 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
nullif there was no mapping for key. Anullreturn can also indicate that the HashMap previously associatednullwith 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 keyksuch that (key==null ? k==null : key.equals(k)). (There can be at most one such mapping.)- Specified by:
containsKeyin interfaceMap<K,V> - Overrides:
containsKeyin 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:
removein interfaceMap<K,V> - Overrides:
removein classHashMap<String,V> - Parameters:
key- key whose mapping is to be removed from the map.- Returns:
- previous value associated with specified key, or
nullif there was no mapping for key. Anullreturn can also indicate that the map previously associatednullwith the specified key.
-