public double getCachedDistanceSq(TileEntity tile) { return distanceCache.getOrDefault(tile, Double.MAX_VALUE); }
/** * 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()); }
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; }
@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); } }