gu.sql2java.guava.MapBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sql2java-base Show documentation
Show all versions of sql2java-base Show documentation
sql2java common class package
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