Class CaseInsensitiveMap<V>

  • Type Parameters:
    V - The type of the case insensitive map.
    All Implemented Interfaces:
    Map<String,​V>

    public class CaseInsensitiveMap<V>
    extends MapDecorator<String,​V>
    An implementation of a map whose keys are case-insensitive strings. All operations match keys in a case-insensitive manner. The original cases of keys are retained, so the keySet() method for example returns the original keys.

    Note: The behavior of this class is undefined when wrapping a map that has keys that would result in duplicate case-insensitive keys.

    • Constructor Detail

      • CaseInsensitiveMap

        public CaseInsensitiveMap()
        Constructs a new empty case-insensitive map. The backing map is a new HashMap with default initial capacity and load factor.
      • CaseInsensitiveMap

        public CaseInsensitiveMap​(Map<String,​V> map)
        Wraps an existing map with a new case insensitive map.
        Parameters:
        map - the map to wrap with a new case insensitive map.
    • Method Detail

      • sync

        public void sync()
        Synchronizes the keys of this case insensitive map and those of the map it is wrapping. This is necessary if the underlying map is modified directly and this map needs to be resynchronized.
      • containsKey

        public boolean containsKey​(Object key)
        Description copied from class: MapDecorator
        Returns true if this map contains a mapping for the specified key.
        Specified by:
        containsKey in interface Map<String,​V>
        Overrides:
        containsKey in class MapDecorator<String,​V>
        Parameters:
        key - the key whose presence in this map is to be tested.
        Returns:
        true if this map contains a mapping for the specified key.
      • put

        public V put​(String key,
                     V value)
        Description copied from class: MapDecorator
        Associates the specified value with the specified key in the map.
        Specified by:
        put in interface Map<String,​V>
        Overrides:
        put in class MapDecorator<String,​V>
        Parameters:
        key - key with which the specified value is to be associated.
        value - value to be associated with the specified key.
        Returns:
        the previous value associated with key, or null if no mapping.
      • putAll

        public void putAll​(Map<? extends String,​? extends V> m)
        Description copied from class: MapDecorator
        Copies all of the mappings from the specified map to the map.
        Specified by:
        putAll in interface Map<String,​V>
        Overrides:
        putAll in class MapDecorator<String,​V>
        Parameters:
        m - mappings to be stored in the map.
      • get

        public V get​(Object key)
        Description copied from class: MapDecorator
        Returns the value to which the specified key is mapped, or null if the map contains no mapping for the key.
        Specified by:
        get in interface Map<String,​V>
        Overrides:
        get in class MapDecorator<String,​V>
        Parameters:
        key - the key whose associated value is to be returned.
        Returns:
        the value to which the specified key is mapped, or null if no mapping.
      • remove

        public V remove​(Object key)
        Description copied from class: MapDecorator
        Removes the mapping for a key from the map if it is present.
        Specified by:
        remove in interface Map<String,​V>
        Overrides:
        remove in class MapDecorator<String,​V>
        Parameters:
        key - key whose mapping is to be removed from the map.
        Returns:
        the previous value associated with key, or null if no mapping.