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

gu.sql2java.guava.MapBuilder Maven / Gradle / Ivy

The newest version!
package gu.sql2java.guava;

import static gu.sql2java.guava.DeepEquivalence.DEEP_EQUIVALENCE;

import java.lang.reflect.Method;
import java.util.concurrent.ConcurrentMap;

import com.google.common.base.Equivalence;
import com.google.common.base.Throwables;
import com.google.common.collect.MapMaker;

/**
 * 
 * @author guyadong
 *
 */
public class MapBuilder {

	/**
	 * 创建支持Object[]为key的map
	 */
	public static  ConcurrentMap newConcurrentMap() {
		
		try {
			// 等价于 new MapMaker().keyEquivalence(DEEP_EQUIVALENCE).makeMap();
			Method method = MapMaker.class.getDeclaredMethod("keyEquivalence", Equivalence.class);
			method.setAccessible(true);
			MapMaker mapMaker= (MapMaker) method.invoke(new MapMaker(), DEEP_EQUIVALENCE);
			return mapMaker.makeMap();
		} catch (Exception e) {
			Throwables.throwIfUnchecked(e);
			throw new RuntimeException(e);
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy