public static Map createInstance() { return new AppMap(); }
/** Constructs an empty HashMap with the specified initial capacity and load factor. */ public AppMap(Map m) { putAll(m); }
@Override public Object put(Object key, Object object) { return super.put(convertKey(key), object); }
/** * Note up to jdk 8 putAll(m) called the put(...) method below similar to the implementation below. * jdk8 must have changed putAll(m) to not call put. This made it so the keys weren't converted to * be case insensitive breaking tests. Hence the following code was added to make this implementation explicit. * @since 2.79 * @param m */ @Override public void putAll(Map m) { Iterator<Map.Entry> iter = m.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = iter.next(); put(entry.getKey(), entry.getValue()); } }
@Override public Object get(Object key) { return super.get(convertKey(key)); }
public Object get(Object key) { return super.get(convertKey(key)); }
public static Map createInstance() { return new AppMap(); }
/** Constructs an empty HashMap with the specified initial capacity and load factor. */ public AppMap(Map m) { putAll(m); }
public Object put(Object key, Object object) { return super.put(convertKey(key), object); }
public static void main(String[] args) { Map map=new HashMap(); map.put("HeLLo", "world"); System.out.println("Should return null: "+map.get("HELLO")); System.out.println("Contents of HashMap="+map); map=new AppMap(map); System.out.println("Should return 'world': "+map.get("HELLO")); System.out.println("Contents of AppMap="+map); }
public boolean containsKey(Object key) { // The normal case is done first as a performance optimization. It seems to make checks around 30% faster // due to only converting the case of the string comparison only when required. return super.containsKey(key) || super.containsKey(convertKey(key)); }
@Override public boolean containsKey(Object key) { // The normal case is done first as a performance optimization. It seems to make checks around 30% faster // due to only converting the case of the string comparison only when required. return super.containsKey(key) || super.containsKey(convertKey(key)); }