T
- The class of the values referenced in the map.public class CaseInsensitiveMapWrapper<T> extends Object implements Map<String,T>, Serializable
T
where the key's case is not taken into account when looking for it, but remembered
when the key set is retrieved from the map. The backing map used will be the Map
instance passed to the constructor.
This allows to make case insensitive different kinds of Map implementations, particularly a ConcurrentHashMap,
used to achieve high concurrence.
When a key/value pair is put in the map the key case is remembered so when the key set or the entry set is retrieved the
correct case is returned. This is useful to store, for example, camel case keys. However, two keys that only differ in their
case will be assumed to be the same key and only one value (the last) will be kept. Note: as this map uses a provided class to
create the backing map, key rewrite is not ensured. It is possible that when redefining a value associated to a key, the key
case won't be overwritten and the already existing key case will remains in the key set and entry set.Modifier and Type | Class and Description |
---|---|
protected static class |
CaseInsensitiveMapWrapper.AbstractConverterSet<A,B> |
protected static class |
CaseInsensitiveMapWrapper.CaseInsensitiveMapKey |
Modifier and Type | Field and Description |
---|---|
protected Map<CaseInsensitiveMapWrapper.CaseInsensitiveMapKey,T> |
baseMap |
Constructor and Description |
---|
CaseInsensitiveMapWrapper()
Creates a new instance using a
HashMap as backing map. |
CaseInsensitiveMapWrapper(Map map)
Creates a new instance using an existing map as backing map.
|
Modifier and Type | Method and Description |
---|---|
Map<String,T> |
asCaseSensitiveMap()
Returns this map as a case sensitive map.
|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Set<Map.Entry<String,T>> |
entrySet() |
T |
get(Object key) |
boolean |
isEmpty() |
Set<String> |
keySet() |
T |
put(String key,
T value) |
void |
putAll(Map<? extends String,? extends T> other) |
T |
remove(Object key) |
int |
size() |
Collection<T> |
values() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
protected final Map<CaseInsensitiveMapWrapper.CaseInsensitiveMapKey,T> baseMap
public CaseInsensitiveMapWrapper(Map map)
map
- existing mappublic CaseInsensitiveMapWrapper()
HashMap
as backing map.public boolean containsKey(Object key)
containsKey
in interface Map<String,T>
public boolean containsValue(Object value)
containsValue
in interface Map<String,T>
Copyright © 2018. All rights reserved.