UTIL_Map.CaseInsensitiveMap
Class
global inherited sharing class UTIL_Map.CaseInsensitiveMapA Map implementation that performs case-insensitive key lookups. Keys are normalised to lower case for internal storage and retrieval, but the original casing is retained for display and export operations.
Since: 1.0
Example:
UTIL_Map.CaseInsensitiveMap ciMap = new UTIL_Map.CaseInsensitiveMap();
ciMap.put('Acme Ltd', myAccount);
Account a = (Account) ciMap.get('ACME LTD');Methods
| Method | Description |
|---|---|
| global CaseInsensitiveMap() | Constructs an empty CaseInsensitiveMap. |
| global CaseInsensitiveMap(Map<String, Object> sourceMap) | Constructs a new CaseInsensitiveMap pre-populated with entries from the provided standard map. |
| global void clear() | Empties this map, discarding all stored entries. |
| global Boolean containsKey(String key) | Checks whether this map holds an entry for the specified key, ignoring letter case. |
| global UTIL_Map.CaseInsensitiveMap copy() | Produces a shallow copy of this CaseInsensitiveMap. |
| global Object get(String key) | Retrieves the value mapped to the supplied key using a case-insensitive comparison. |
| global Boolean isEmpty() | Indicates whether this map is empty, containing zero entries. |
| global Set keySet() | Returns the set of keys in their original, caller-supplied casing. |
| global void put(String key, Object value) | Stores a value under the given key. |
| global void putAll(Map<String, Object> sourceMap) | Inserts all entries from the supplied map into this map. |
| global Object remove(String key) | Deletes the entry for the given key (case-insensitive match) and returns the previously associated value. |
| global Integer size() | Returns the current number of key-value mappings stored in this map. |
| global Map toMap() | Exports the contents of this map to a standard Map, restoring the original key casing. |
| global List values() | Returns all values stored in this map as an ordered list. |
Method Details
CaseInsensitiveMap
global CaseInsensitiveMap()Constructs an empty CaseInsensitiveMap.
Since: 1.0
Example:
UTIL_Map.CaseInsensitiveMap instance = new UTIL_Map.CaseInsensitiveMap();CaseInsensitiveMap
global CaseInsensitiveMap(Map<String, Object> sourceMap)Constructs a new CaseInsensitiveMap pre-populated with entries from the provided standard map.
Parameters:
sourceMap(Map) - The map whose entries are to be placed into this map.
Since: 1.0
Example:
UTIL_Map.CaseInsensitiveMap instance = new UTIL_Map.CaseInsensitiveMap(new Map<String, Object>{'key' => 'value'});clear
global void clear()Empties this map, discarding all stored entries.
Since: 1.0
Example:
instance.clear();containsKey
global Boolean containsKey(String key)Checks whether this map holds an entry for the specified key, ignoring letter case.
Parameters:
key(String) - The key whose presence in this map is to be tested.
Returns: Boolean - Boolean true if this map contains a mapping for the specified key, otherwise false.
Since: 1.0
Example:
Boolean result = instance.containsKey('value');copy
global UTIL_Map.CaseInsensitiveMap copy()Produces a shallow copy of this CaseInsensitiveMap. The returned instance is independent; mutations do not propagate between the original and the copy.
Returns: UTIL_Map.CaseInsensitiveMap - A new CaseInsensitiveMap instance that is a copy of this one.
Since: 1.0
Example:
CaseInsensitiveMap result = instance.copy();get
global Object get(String key)Retrieves the value mapped to the supplied key using a case-insensitive comparison. Returns null when no mapping exists.
Parameters:
key(String) - The key whose associated value is to be returned.
Returns: Object - The value associated with the key, or null if no mapping exists.
Since: 1.0
Example:
Object result = instance.get('value');isEmpty
global Boolean isEmpty()Indicates whether this map is empty, containing zero entries.
Returns: Boolean - Boolean true if the map is empty, otherwise false.
Since: 1.0
Example:
Boolean result = instance.isEmpty();keySet
global Set<String> keySet()Returns the set of keys in their original, caller-supplied casing.
Returns: String - A Set of the original keys in the map.
Since: 1.0
Example:
Set<String> result = instance.keySet();put
global void put(String key, Object value)Stores a value under the given key. If a mapping already exists for the same key (regardless of letter case), it is replaced.
Parameters:
key(String) - The key with which the specified value is to be associated.value(Object) - The value to be associated with the specified key.
Since: 1.0
Example:
instance.put('value', 'value');putAll
global void putAll(Map<String, Object> sourceMap)Inserts all entries from the supplied map into this map. Existing mappings whose keys match (case-insensitively) are overwritten.
Parameters:
sourceMap(Map) - The map whose entries are to be placed into this map.
Since: 1.0
Example:
instance.putAll(new Map<String, Object>{'key' => 'value'});remove
global Object remove(String key)Deletes the entry for the given key (case-insensitive match) and returns the previously associated value.
Parameters:
key(String) - The key whose mapping is to be removed from the map.
Returns: Object - The previous value associated with the key, or null if there was no mapping for the key.
Since: 1.0
Example:
Object result = instance.remove('value');size
global Integer size()Returns the current number of key-value mappings stored in this map.
Returns: Integer - The number of entries in the map.
Since: 1.0
Example:
Integer result = instance.size();toMap
global Map<String, Object> toMap()Exports the contents of this map to a standard Map , restoring the original key casing.
Returns: Object - A new Map<String, Object> containing all entries from this map.
Since: 1.0
Example:
Map<String, Object> result = instance.toMap();values
global List<Object> values()Returns all values stored in this map as an ordered list.
Returns: Object - A List of the values in the map.
Since: 1.0
Example:
List<Object> result = instance.values();