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

org.onetwo.common.utils.map.CaseInsensitiveMap Maven / Gradle / Ivy

There is a newer version: 4.7.2
Show newest version
package org.onetwo.common.utils.map;

/****
 * key不区分大小写
 * @author way
 *
 * @param 
 * @param 
 */
@SuppressWarnings({ "unchecked"})
public class CaseInsensitiveMap extends BaseMap{
	
	public CaseInsensitiveMap() {
		super();
	}


	public CaseInsensitiveMap(int initialCapacity) {
		super(initialCapacity);
	}
	

	@Override
	public boolean containsKey(Object key) {
		return super.containsKey(convertKey(key));
	}


	@Override
	public V get(Object key) {
		key = convertKey(key);
		return super.get(key);
	}
	
	protected Object convertKey(Object key){
		if(key instanceof String){
			key = key.toString().toLowerCase();
		}
		return key;
	}

	@Override
	public V put(K key, V value) {
		key = (K)convertKey(key);
		return super.put(key, value);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy