Serializable, Cloneable, Map<String,V>public class IgnoreCaseMap<V> extends AbstractMap<K,V> implements Serializable, Cloneable
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.
Map,
Serialized FormAbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>| Modifier and Type | Field | Description |
|---|---|---|
protected Map<K,Map.Entry<K,V>> |
entries |
|
protected int |
modCount |
| Constructor | Description |
|---|---|
IgnoreCaseMap() |
Constructs a new empty
Map. |
IgnoreCaseMap(Map<String,? extends V> pMap) |
Constructs a new
Map with the same key-value mappings as the
given Map. |
IgnoreCaseMap(Map pBacking,
Map<String,? extends V> pContents) |
Constructs a new
Map with the same key-value mappings as the
given Map. |
| Modifier and Type | Method | Description |
|---|---|---|
void |
clear() |
|
protected Object |
clone() |
Returns a shallow copy of this
AbstractMap instance: the keys
and values themselves are not cloned. |
boolean |
containsKey(Object pKey) |
Tests if the specified object is a key in this map.
|
boolean |
containsValue(Object pValue) |
Returns
true if this map maps one or more keys to the
specified pValue. |
Set<Map.Entry<K,V>> |
entrySet() |
|
V |
get(Object pKey) |
Returns the value to which the specified key is mapped in this
map.
|
protected void |
init() |
Default implementation, does nothing.
|
boolean |
isEmpty() |
|
Set<K> |
keySet() |
|
protected Iterator<Map.Entry<String,V>> |
newEntryIterator() |
|
protected Iterator<String> |
newKeyIterator() |
|
protected Iterator<V> |
newValueIterator() |
|
V |
put(String pKey,
V pValue) |
Maps the specified key to the specified value in this map.
|
V |
remove(Object pKey) |
Removes the key (and its corresponding value) from this map.
|
protected Map.Entry<K,V> |
removeEntry(Map.Entry<K,V> pEntry) |
Removes the given entry from the Map.
|
int |
size() |
|
protected static Object |
toUpper(Object pObject) |
Converts the parameter to uppercase, if it's a String.
|
Collection<V> |
values() |
equals, hashCode, putAll, toStringcompute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putAll, putIfAbsent, remove, replace, replace, replaceAllpublic IgnoreCaseMap()
Map.
The backing map will be a HashMappublic IgnoreCaseMap(Map<String,? extends V> pMap)
Map with the same key-value mappings as the
given Map.
The backing map will be a HashMap
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.pMap - the map whose mappings are to be placed in this map.public IgnoreCaseMap(Map pBacking, Map<String,? extends V> pContents)
Map with the same key-value mappings as the
given Map.
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.pBacking - the backing map of this map. Must be either empty, or
the same map as pContents.pContents - the map whose mappings are to be placed in this map.
May be nullIllegalArgumentException - if pBacking is nullIllegalArgumentException - if pBacking differs from
pContent and is not empty.public V put(String pKey, V pValue)
public V get(Object pKey)
public V remove(Object pKey)
public boolean containsKey(Object pKey)
containsKey in interface Map<String,V>pKey - possible key.protected static Object toUpper(Object pObject)
protected void init()
public int size()
size in interface Map<K,V>size in class AbstractMap<K,V>public void clear()
clear in interface Map<K,V>clear in class AbstractMap<K,V>public boolean isEmpty()
isEmpty in interface Map<K,V>isEmpty in class AbstractMap<K,V>public boolean containsValue(Object pValue)
true if this map maps one or more keys to the
specified pValue. More formally, returns true if and only if
this map contains at least one mapping to a pValue v such that
(pValue==null ? v==null : pValue.equals(v)).
This implementation requires time linear in the map size for this
operation.containsValue in interface Map<K,V>containsValue in class AbstractMap<K,V>pValue - pValue whose presence in this map is to be tested.true if this map maps one or more keys to the
specified pValue.public Collection<V> values()
values in interface Map<K,V>values in class AbstractMap<K,V>public Set<Map.Entry<K,V>> entrySet()
entrySet in interface Map<K,V>entrySet in class AbstractMap<K,V>public Set<K> keySet()
keySet in interface Map<K,V>keySet in class AbstractMap<K,V>protected Object clone() throws CloneNotSupportedException
AbstractMap instance: the keys
and values themselves are not cloned.clone in class AbstractMap<K,V>CloneNotSupportedExceptionCopyright © 2018. All rights reserved.