public class CaseInsensitiveMap<K,V> extends Object implements Map<K,V>
The internal CaseInsensitiveString is never exposed externally from this class. When requesting the keys or entries of this map, or calling containsKey() or get() for example, use a String as you normally would. The returned Set of keys for the keySet() and entrySet() APIs return the original Strings, not the internally wrapped CaseInsensitiveString. As an added benefit, .keySet() returns a case-insenstive Set, however, again, the contents of the entries are actual Strings. Similarly, .entrySet() returns a case-insensitive entry set, such that .getKey() on the entry is case insensitive when compared, but the returned key is a String.
Modifier and Type | Class and Description |
---|---|
class |
CaseInsensitiveMap.CaseInsensitiveEntry
Entry implementation that will give back a String instead of a CaseInsensitiveString
when .getKey() is called.
|
static class |
CaseInsensitiveMap.CaseInsensitiveString
Class used to wrap String keys.
|
Constructor and Description |
---|
CaseInsensitiveMap() |
CaseInsensitiveMap(int initialCapacity)
Use the constructor that takes two (2) Maps.
|
CaseInsensitiveMap(int initialCapacity,
float loadFactor)
Use the constructor that takes two (2) Maps.
|
CaseInsensitiveMap(Map<K,V> m)
Wrap the passed in Map with a CaseInsensitiveMap, allowing other Map types like
TreeMap, ConcurrentHashMap, etc.
|
CaseInsensitiveMap(Map<K,V> source,
Map<K,V> mapInstance)
Wrap the passed in Map with a CaseInsensitiveMap, allowing other Map types like
TreeMap, ConcurrentHashMap, etc.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
protected Map<K,V> |
copy(Map<K,V> source,
Map<K,V> dest) |
Set<Map.Entry<K,V>> |
entrySet() |
boolean |
equals(Object other) |
V |
get(Object key) |
Map<K,V> |
getWrappedMap() |
int |
hashCode() |
boolean |
isEmpty() |
Set<K> |
keySet()
Returns a Set view of the keys contained in this map.
|
Map |
minus(Object removeMe) |
Map |
plus(Object right) |
V |
put(K key,
V value) |
void |
putAll(Map<? extends K,? extends V> m) |
Object |
putObject(Object key,
Object value) |
V |
remove(Object key) |
int |
size() |
String |
toString() |
Collection<V> |
values() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public CaseInsensitiveMap()
public CaseInsensitiveMap(int initialCapacity)
public CaseInsensitiveMap(int initialCapacity, float loadFactor)
public CaseInsensitiveMap(Map<K,V> source, Map<K,V> mapInstance)
source
- existing Map to supply the entries.mapInstance
- empty new Map to use. This lets you decide what Map to use to back the CaseInsensitiveMap.public boolean containsKey(Object key)
containsKey
in interface Map<K,V>
public boolean equals(Object other)
public int hashCode()
public boolean containsValue(Object value)
containsValue
in interface Map<K,V>
public Set<K> keySet()
Copyright © 2023. All rights reserved.