Package com.aspectran.utils
Class LinkedCaseInsensitiveMap<V>
java.lang.Object
com.aspectran.utils.LinkedCaseInsensitiveMap<V>
- Type Parameters:
V
- the value type
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<String,
V>
public class LinkedCaseInsensitiveMap<V>
extends Object
implements Map<String,V>, Serializable, Cloneable
This class is a clone of org.springframework.util.LinkedCaseInsensitiveMap
LinkedHashMap
variant that stores String keys in a case-insensitive
manner, for example for key-based access in a results table.
Preserves the original order as well as the original casing of keys, while allowing for contains, get and remove calls with any case of key.
Does not support null
keys.
- Author:
- Juergen Hoeller, Phillip Webb
- See Also:
-
Nested Class Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new LinkedCaseInsensitiveMap that stores case-insensitive keys according to the default Locale (by default in lower case).LinkedCaseInsensitiveMap
(int initialCapacity) Create a new LinkedCaseInsensitiveMap that wraps aLinkedHashMap
with the given initial capacity and stores case-insensitive keys according to the default Locale (by default in lower case).LinkedCaseInsensitiveMap
(int initialCapacity, Locale locale) Create a new LinkedCaseInsensitiveMap that wraps aLinkedHashMap
with the given initial capacity and stores case-insensitive keys according to the given Locale (by default in lower case).LinkedCaseInsensitiveMap
(Locale locale) Create a new LinkedCaseInsensitiveMap that stores case-insensitive keys according to the given Locale (by default in lower case). -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
clone()
computeIfAbsent
(String key, Function<? super String, ? extends V> mappingFunction) boolean
containsKey
(Object key) boolean
containsValue
(Object value) protected String
convertKey
(String key) Convert the given key to a case-insensitive key.entrySet()
boolean
void
forEach
(BiConsumer<? super String, ? super V> action) Return the locale used by thisLinkedCaseInsensitiveMap
.getOrDefault
(Object key, V defaultValue) int
hashCode()
boolean
isEmpty()
keySet()
void
putIfAbsent
(String key, V value) protected boolean
removeEldestEntry
(Map.Entry<String, V> eldest) Determine whether this map should remove the given eldest entry.int
size()
toString()
values()
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfPresent, merge, remove, replace, replace, replaceAll
-
Constructor Details
-
LinkedCaseInsensitiveMap
public LinkedCaseInsensitiveMap()Create a new LinkedCaseInsensitiveMap that stores case-insensitive keys according to the default Locale (by default in lower case).- See Also:
-
LinkedCaseInsensitiveMap
Create a new LinkedCaseInsensitiveMap that stores case-insensitive keys according to the given Locale (by default in lower case).- Parameters:
locale
- the Locale to use for case-insensitive key conversion- See Also:
-
LinkedCaseInsensitiveMap
public LinkedCaseInsensitiveMap(int initialCapacity) Create a new LinkedCaseInsensitiveMap that wraps aLinkedHashMap
with the given initial capacity and stores case-insensitive keys according to the default Locale (by default in lower case).- Parameters:
initialCapacity
- the initial capacity- See Also:
-
LinkedCaseInsensitiveMap
Create a new LinkedCaseInsensitiveMap that wraps aLinkedHashMap
with the given initial capacity and stores case-insensitive keys according to the given Locale (by default in lower case).- Parameters:
initialCapacity
- the initial capacitylocale
- the Locale to use for case-insensitive key conversion- See Also:
-
-
Method Details
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<String,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<String,
V>
-
get
-
getOrDefault
- Specified by:
getOrDefault
in interfaceMap<String,
V>
-
put
-
putAll
-
putIfAbsent
- Specified by:
putIfAbsent
in interfaceMap<String,
V>
-
computeIfAbsent
@Nullable public V computeIfAbsent(String key, @NonNull Function<? super String, ? extends V> mappingFunction) - Specified by:
computeIfAbsent
in interfaceMap<String,
V>
-
remove
-
clear
public void clear() -
keySet
-
values
-
entrySet
-
forEach
-
clone
-
equals
-
hashCode
public int hashCode() -
toString
-
getLocale
Return the locale used by thisLinkedCaseInsensitiveMap
. Used for case-insensitive key conversion. -
convertKey
Convert the given key to a case-insensitive key.The default implementation converts the key to lower-case according to this Map's Locale.
- Parameters:
key
- the user-specified key- Returns:
- the key to use for storing
- See Also:
-
removeEldestEntry
Determine whether this map should remove the given eldest entry.- Parameters:
eldest
- the candidate entry- Returns:
true
for removing it,false
for keeping it
-