package com.txtr.hibernatedelta.util; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; /** * A simple map delegate that stores and retrieves map keys in a case-insensitive fashion. * @author nico */ public class CaseInsensitiveMap { private final Map<String, String> map; public CaseInsensitiveMap() { map = new LinkedHashMap<String, String>(); } public CaseInsensitiveMap(final CaseInsensitiveMap copyFrom) { map = new LinkedHashMap<String, String>(copyFrom.map); } public final String get(final String key) { return map.get(key.toLowerCase()); } public final String put(final String key, final String value) { return map.put(key.toLowerCase(), value); } /** * @return the entries with lower case keys */ public final Set<Map.Entry<String, String>> entrySet() { return map.entrySet(); } /** * @return the lower case keys */ public Set<String> keySet() { return map.keySet(); } @Override public final boolean equals(final Object other) { if (other != null && other instanceof CaseInsensitiveMap) { return map.equals(((CaseInsensitiveMap) other).map); } else { return false; } } @Override public final int hashCode() { return map.hashCode(); } @Override public final String toString() { return map.toString(); } }