Package com.aspectran.core.util
Class LinkedCaseInsensitiveMap<V>
- java.lang.Object
-
- com.aspectran.core.util.LinkedCaseInsensitiveMap<V>
-
- Type Parameters:
V
- the value type
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.util.Map<java.lang.String,V>
public class LinkedCaseInsensitiveMap<V> extends java.lang.Object implements java.util.Map<java.lang.String,V>, java.io.Serializable, java.lang.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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LinkedCaseInsensitiveMap()
Create 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, java.util.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(java.util.Locale locale)
Create a new LinkedCaseInsensitiveMap that stores case-insensitive keys according to the given Locale (by default in lower case).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
LinkedCaseInsensitiveMap<V>
clone()
V
computeIfAbsent(java.lang.String key, java.util.function.Function<? super java.lang.String,? extends V> mappingFunction)
boolean
containsKey(java.lang.Object key)
boolean
containsValue(java.lang.Object value)
protected java.lang.String
convertKey(java.lang.String key)
Convert the given key to a case-insensitive key.java.util.Set<java.util.Map.Entry<java.lang.String,V>>
entrySet()
boolean
equals(java.lang.Object obj)
V
get(java.lang.Object key)
java.util.Locale
getLocale()
Return the locale used by thisLinkedCaseInsensitiveMap
.V
getOrDefault(java.lang.Object key, V defaultValue)
int
hashCode()
boolean
isEmpty()
java.util.Set<java.lang.String>
keySet()
V
put(java.lang.String key, V value)
void
putAll(java.util.Map<? extends java.lang.String,? extends V> map)
V
putIfAbsent(java.lang.String key, V value)
V
remove(java.lang.Object key)
protected boolean
removeEldestEntry(java.util.Map.Entry<java.lang.String,V> eldest)
Determine whether this map should remove the given eldest entry.int
size()
java.lang.String
toString()
java.util.Collection<V>
values()
-
-
-
Constructor Detail
-
LinkedCaseInsensitiveMap
public LinkedCaseInsensitiveMap()
Create a new LinkedCaseInsensitiveMap that stores case-insensitive keys according to the default Locale (by default in lower case).- See Also:
convertKey(String)
-
LinkedCaseInsensitiveMap
public LinkedCaseInsensitiveMap(@Nullable java.util.Locale locale)
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:
convertKey(String)
-
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:
convertKey(String)
-
LinkedCaseInsensitiveMap
public LinkedCaseInsensitiveMap(int initialCapacity, @Nullable java.util.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).- Parameters:
initialCapacity
- the initial capacitylocale
- the Locale to use for case-insensitive key conversion- See Also:
convertKey(String)
-
-
Method Detail
-
size
public int size()
- Specified by:
size
in interfacejava.util.Map<java.lang.String,V>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfacejava.util.Map<java.lang.String,V>
-
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKey
in interfacejava.util.Map<java.lang.String,V>
-
containsValue
public boolean containsValue(java.lang.Object value)
- Specified by:
containsValue
in interfacejava.util.Map<java.lang.String,V>
-
get
@Nullable public V get(java.lang.Object key)
- Specified by:
get
in interfacejava.util.Map<java.lang.String,V>
-
getOrDefault
@Nullable public V getOrDefault(java.lang.Object key, V defaultValue)
- Specified by:
getOrDefault
in interfacejava.util.Map<java.lang.String,V>
-
put
@Nullable public V put(java.lang.String key, @Nullable V value)
- Specified by:
put
in interfacejava.util.Map<java.lang.String,V>
-
putAll
public void putAll(java.util.Map<? extends java.lang.String,? extends V> map)
- Specified by:
putAll
in interfacejava.util.Map<java.lang.String,V>
-
putIfAbsent
@Nullable public V putIfAbsent(java.lang.String key, @Nullable V value)
- Specified by:
putIfAbsent
in interfacejava.util.Map<java.lang.String,V>
-
computeIfAbsent
@Nullable public V computeIfAbsent(java.lang.String key, java.util.function.Function<? super java.lang.String,? extends V> mappingFunction)
- Specified by:
computeIfAbsent
in interfacejava.util.Map<java.lang.String,V>
-
remove
@Nullable public V remove(java.lang.Object key)
- Specified by:
remove
in interfacejava.util.Map<java.lang.String,V>
-
clear
public void clear()
- Specified by:
clear
in interfacejava.util.Map<java.lang.String,V>
-
keySet
@NonNull public java.util.Set<java.lang.String> keySet()
- Specified by:
keySet
in interfacejava.util.Map<java.lang.String,V>
-
values
@NonNull public java.util.Collection<V> values()
- Specified by:
values
in interfacejava.util.Map<java.lang.String,V>
-
entrySet
@NonNull public java.util.Set<java.util.Map.Entry<java.lang.String,V>> entrySet()
- Specified by:
entrySet
in interfacejava.util.Map<java.lang.String,V>
-
clone
public LinkedCaseInsensitiveMap<V> clone()
- Overrides:
clone
in classjava.lang.Object
-
equals
public boolean equals(@Nullable java.lang.Object obj)
- Specified by:
equals
in interfacejava.util.Map<java.lang.String,V>
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfacejava.util.Map<java.lang.String,V>
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getLocale
public java.util.Locale getLocale()
Return the locale used by thisLinkedCaseInsensitiveMap
. Used for case-insensitive key conversion.
-
convertKey
protected java.lang.String convertKey(java.lang.String key)
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:
String.toLowerCase(Locale)
-
removeEldestEntry
protected boolean removeEldestEntry(java.util.Map.Entry<java.lang.String,V> eldest)
Determine whether this map should remove the given eldest entry.- Parameters:
eldest
- the candidate entry- Returns:
true
for removing it,false
for keeping it
-
-