本文整理了Java中java.util.WeakHashMap.getOrDefault()
方法的一些代码示例,展示了WeakHashMap.getOrDefault()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WeakHashMap.getOrDefault()
方法的具体详情如下:
包路径:java.util.WeakHashMap
类名称:WeakHashMap
方法名:getOrDefault
暂无
代码示例来源:origin: TeamWizardry/Wizardry
public double getCachedDistanceSq(TileEntity tile) {
return distanceCache.getOrDefault(tile, Double.MAX_VALUE);
}
代码示例来源:origin: com.holon-platform.core/holon-core
/**
* Get default Holon configuration properties providers
* @param classLoader ClassLoader to use (not null)
* @return Holon configuration properties providers, or an empty list if none available
*/
public static List<ConfigPropertyProvider> defaultConfigPropertyProviders(ClassLoader classLoader) {
ObjectUtils.argumentNotNull(classLoader, "ClassLoader must be not null");
return configPropertyProviders.getOrDefault(classLoader, Collections.emptyList());
}
代码示例来源:origin: sc.fiji/bigdataviewer-vistools
public static synchronized int getUnusedSetupId( SetupAssignments setupAssignments )
{
if ( setupAssignments == null )
setupAssignments = nullSetupAssignmentsKey;
int maxId = maxIds.getOrDefault( setupAssignments, 0 );
for ( final ConverterSetup setup : setupAssignments.getConverterSetups() )
maxId = Math.max( setup.getSetupId(), maxId );
++maxId;
maxIds.put( setupAssignments, maxId );
return maxId;
}
代码示例来源:origin: com.holon-platform.jpa/holon-datastore-jpa-querydsl
@SuppressWarnings("unchecked")
public static <T> EntityPath<T> resolvePath(ClassLoader classLoader, Class<? extends T> domainClass) {
final ClassLoader cl = (classLoader != null) ? classLoader : ClassUtils.getDefaultClassLoader();
// check cache
Map<Class, EntityPath> mappings = ENTITY_PATHS.getOrDefault(cl, Collections.emptyMap());
if (mappings.containsKey(domainClass)) {
return mappings.get(domainClass);
}
String pathClassName = getQueryClassName(domainClass);
try {
Class<?> pathClass = Class.forName(pathClassName, true, domainClass.getClassLoader());
Field field = getStaticFieldOfType(pathClass);
if (field == null) {
throw new IllegalStateException("Static field of type " + pathClass.getName() + " not found");
} else {
EntityPath entityPath = (EntityPath) field.get(null);
if (entityPath != null) {
// cache value
ENTITY_PATHS.computeIfAbsent(cl, c -> new HashMap<>()).put(domainClass, entityPath);
}
return entityPath;
}
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException(
"Query class " + pathClassName + " not found for domain class " + domainClass.getName(), e);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException("Failed to get static field value for field", e);
}
}
内容来源于网络,如有侵权,请联系作者删除!