Code example for MapMaker

0
    private static final Logger LOGGER = LoggerFactory.getLogger(ClasspathInferer.class);
    private final Lock lock = new ReentrantLock();
    private final Map<Class<?>, Collection<URL>> classPathCache;
 
    public ClasspathInferer() { 
        this.classPathCache = new MapMaker().weakKeys().makeMap();
    } 
 
    public void getClassPathFor(Class<?> targetClass, Collection<URL> dest) {
        lock.lock();
        try { 
            Collection<URL> classPath = classPathCache.get(targetClass);
            if (classPath == null) { 
                Set<Class<?>> visited = new HashSet<Class<?>>();
                classPath = new LinkedHashSet<URL>();
                find(targetClass, visited, classPath);
                classPathCache.put(targetClass, classPath);
            } 
            dest.addAll(classPath); 
        } finally { 
Experience pair programming with AI  Get Codota for Java