Package org.forgerock.http.util
Class CaseInsensitiveMap<V>
- java.lang.Object
-
- org.forgerock.util.MapDecorator<String,V>
-
- org.forgerock.http.util.CaseInsensitiveMap<V>
-
- Type Parameters:
V
- The type of the case insensitive map.
public class CaseInsensitiveMap<V> extends MapDecorator<String,V>
An implementation of a map whose keys are case-insensitive strings. All operations match keys in a case-insensitive manner. The original cases of keys are retained, so thekeySet()
method for example returns the original keys.Note: The behavior of this class is undefined when wrapping a map that has keys that would result in duplicate case-insensitive keys.
-
-
Field Summary
-
Fields inherited from class org.forgerock.util.MapDecorator
map
-
-
Constructor Summary
Constructors Constructor Description CaseInsensitiveMap()
Constructs a new empty case-insensitive map.CaseInsensitiveMap(Map<String,V> map)
Wraps an existing map with a new case insensitive map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Removes all of the mappings from the map.boolean
containsKey(Object key)
Returnstrue
if this map contains a mapping for the specified key.V
get(Object key)
Returns the value to which the specified key is mapped, ornull
if the map contains no mapping for the key.V
put(String key, V value)
Associates the specified value with the specified key in the map.void
putAll(Map<? extends String,? extends V> m)
Copies all of the mappings from the specified map to the map.V
remove(Object key)
Removes the mapping for a key from the map if it is present.void
sync()
Synchronizes the keys of this case insensitive map and those of the map it is wrapping.-
Methods inherited from class org.forgerock.util.MapDecorator
containsValue, entrySet, equals, hashCode, isEmpty, keySet, size, values
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Constructor Detail
-
CaseInsensitiveMap
public CaseInsensitiveMap()
Constructs a new empty case-insensitive map. The backing map is a newHashMap
with default initial capacity and load factor.
-
-
Method Detail
-
sync
public void sync()
Synchronizes the keys of this case insensitive map and those of the map it is wrapping. This is necessary if the underlying map is modified directly and this map needs to be resynchronized.
-
clear
public void clear()
Description copied from class:MapDecorator
Removes all of the mappings from the map.
-
containsKey
public boolean containsKey(Object key)
Description copied from class:MapDecorator
Returnstrue
if this map contains a mapping for the specified key.- Specified by:
containsKey
in interfaceMap<String,V>
- Overrides:
containsKey
in classMapDecorator<String,V>
- Parameters:
key
- the key whose presence in this map is to be tested.- Returns:
true
if this map contains a mapping for the specified key.
-
put
public V put(String key, V value)
Description copied from class:MapDecorator
Associates the specified value with the specified key in the map.
-
putAll
public void putAll(Map<? extends String,? extends V> m)
Description copied from class:MapDecorator
Copies all of the mappings from the specified map to the map.
-
get
public V get(Object key)
Description copied from class:MapDecorator
Returns the value to which the specified key is mapped, ornull
if the map contains no mapping for the key.
-
remove
public V remove(Object key)
Description copied from class:MapDecorator
Removes the mapping for a key from the map if it is present.
-
-