Class IgnoreCaseMap<V>
- All Implemented Interfaces:
Serializable, Cloneable, Map<String,V>
public class IgnoreCaseMap<V>
extends AbstractDecoratedMap<String,V>
implements Serializable, Cloneable
A
Map decorator that makes the mappings in the backing map
case insensitive
(this is implemented by converting all keys to uppercase),
if the keys used are Strings. If the keys
used are not Strings, it wil work as a normal
java.util.Map.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractDecoratedMap
AbstractDecoratedMap.BasicEntry<K,V>, AbstractDecoratedMap.EntrySet, AbstractDecoratedMap.KeySet, AbstractDecoratedMap.Values Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
Fields inherited from class AbstractDecoratedMap
entries, modCount -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new emptyMap.IgnoreCaseMap(Map<String, ? extends V> pMap) Constructs a newMapwith the same key-value mappings as the givenMap.IgnoreCaseMap(Map pBacking, Map<String, ? extends V> pContents) Constructs a newMapwith the same key-value mappings as the givenMap. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(Object pKey) Tests if the specified object is a key in this map.Returns the value to which the specified key is mapped in this map.Maps the specified key to the specified value in this map.Removes the key (and its corresponding value) from this map.protected static ObjectConverts the parameter to uppercase, if it's a String.private VMethods inherited from class AbstractDecoratedMap
clear, clone, containsValue, createEntry, entrySet, getEntry, init, isEmpty, keySet, removeEntry, size, valuesMethods inherited from class AbstractMap
equals, hashCode, putAll, toStringMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
IgnoreCaseMap
public IgnoreCaseMap()Constructs a new emptyMap. The backing map will be aHashMap -
IgnoreCaseMap
Constructs a newMapwith the same key-value mappings as the givenMap. The backing map will be aHashMapNOTE: As the keys in the given map parameter will be converted to uppercase (if they are strings), any duplicate key/value pair where
key instanceof String && key.equalsIgnoreCase(otherKey)is true, will be lost.- Parameters:
pMap- the map whose mappings are to be placed in this map.
-
IgnoreCaseMap
Constructs a newMapwith the same key-value mappings as the givenMap.NOTE: The backing map is structuraly cahnged, and it should NOT be accessed directly, after the wrapped map is created.
NOTE: As the keys in the given map parameter will be converted to uppercase (if they are strings), any duplicate key/value pair where
key instanceof String && key.equalsIgnoreCase(otherKey)is true, will be lost.- Parameters:
pBacking- the backing map of this map. Must be either empty, or the same map aspContents.pContents- the map whose mappings are to be placed in this map. May benull- Throws:
IllegalArgumentException- ifpBackingisnullIllegalArgumentException- ifpBackingdiffers frompContentand is not empty.
-
-
Method Details
-
put
Maps the specified key to the specified value in this map. Note: If the key used is a string, the key will not be case-sensitive. -
unwrap
-
get
Returns the value to which the specified key is mapped in this map. Note: If the key used is a string, the key will not be case-sensitive. -
remove
Removes the key (and its corresponding value) from this map. This method does nothing if the key is not in the map. Note: If the key used is a string, the key will not be case-sensitive. -
containsKey
Tests if the specified object is a key in this map. Note: If the key used is a string, the key will not be case-sensitive.- Specified by:
containsKeyin interfaceMap<String,V> - Overrides:
containsKeyin classAbstractDecoratedMap<String,V> - Parameters:
pKey- possible key.- Returns:
- true if and only if the specified object is a key in this map, as determined by the equals method; false otherwise.
-
toUpper
-
newEntryIterator
- Specified by:
newEntryIteratorin classAbstractDecoratedMap<String,V>
-
newKeyIterator
- Specified by:
newKeyIteratorin classAbstractDecoratedMap<String,V>
-
newValueIterator
- Specified by:
newValueIteratorin classAbstractDecoratedMap<String,V>
-