All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.silentgo.orm.common.CaseInsensitiveHashMap Maven / Gradle / Ivy

There is a newer version: 0.3.2
Show newest version
package com.silentgo.orm.common;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;

/**
 * Project : silentgo
 * com.silentgo.orm.common
 *
 * @author teddyzhu
 *         

* Created by teddyzhu on 16/9/21. */ public class CaseInsensitiveHashMap extends LinkedHashMap { private final Map lowerCaseMap = new HashMap<>(); @Override public boolean containsKey(Object key) { Object realKey = lowerCaseMap.get(key.toString().toLowerCase(Locale.ENGLISH)); return super.containsKey(realKey); } @Override public Object get(Object key) { Object realKey = lowerCaseMap.get(key.toString().toLowerCase(Locale.ENGLISH)); return super.get(realKey); } @Override public Object put(String key, Object value) { Object oldKey = lowerCaseMap.put(key.toLowerCase(Locale.ENGLISH), key); Object oldValue = super.remove(oldKey); super.put(key, value); return oldValue; } @Override public void putAll(Map m) { for (Map.Entry entry : m.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); this.put(key, value); } } @Override public Object remove(Object key) { Object realKey = lowerCaseMap.remove(key.toString().toLowerCase(Locale.ENGLISH)); return super.remove(realKey); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy