Class CaseInsensitiveMap<T>

java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<String,T>
com.saperion.common.lang.collection.CaseInsensitiveMap<T>
Type Parameters:
T - the type of mapped values
All Implemented Interfaces:
Serializable, Cloneable, Map<String,T>

public class CaseInsensitiveMap<T> extends HashMap<String,T>

A CaseInsensitiveMap is a specialized HashMap with case insensitive keys of type String.

All keys will be converted with String.toLowerCase(Locale) with Locale.ENGLISH.

The keys are stored internally in lower case and all requests convert the specified key first and than compare it with the stored key as usual with Object.equals(Object).

This implementation is not synchronized. If used by different threads concurrently, external synchronization is necessary.

Author:
chm, agz
See Also:
  • Constructor Details

    • CaseInsensitiveMap

      public CaseInsensitiveMap()
      Constructs an empty CaseInsensitiveMap with the default initial capacity (16) and the default load factor (0.75).
    • CaseInsensitiveMap

      public CaseInsensitiveMap(int initialCapacity, float loadFactor)
      Constructs an empty CaseInsensitiveMap with the specified initial capacity and load factor.
      Parameters:
      initialCapacity - the initial capacity
      loadFactor - the load factor
      Throws:
      IllegalArgumentException - if the initial capacity is negative or the load factor is non-positive
    • CaseInsensitiveMap

      public CaseInsensitiveMap(int initialCapacity)
      Constructs an empty CaseInsensitiveMap with the specified initial capacity and the default load factor (0.75).
      Parameters:
      initialCapacity - the initial capacity.
      Throws:
      IllegalArgumentException - if the initial capacity is negative.
    • CaseInsensitiveMap

      public CaseInsensitiveMap(Map<? extends String,? extends T> map)
      Constructs a new CaseInsensitiveMap with the same mappings as the specified Map. The CaseInsensitiveMap is created with default load factor (0.75) and an initial capacity sufficient to hold the mappings in the specified Map.
      Parameters:
      map - the Map whose mappings are to be placed in this map
      Throws:
      NullPointerException - if the specified map is null
  • Method Details