
org.intermine.util.ReferenceMap Maven / Gradle / Ivy
package org.intermine.util;
/*
* Copyright (C) 2002-2022 FlyMine
*
* This code may be freely distributed and modified under the
* terms of the GNU Lesser General Public Licence. This should
* be distributed with the code. See the LICENSE file for more
* information or http://www.gnu.org/copyleft/lesser.html.
*
*/
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import org.apache.log4j.Logger;
/**
* This is a Map implementation designed specifically for people intending to create a cache.
* The class should be subclassed to provide soft or weak reference behaviour. The keys are held
* strongly, but the values are held weakly or softly, so the values can be garbage-collected.
* When an entry is garbage-collected, its key is removed from the Map on the next Map activity.
*
* The entrySet() and values() methods of this class do not work.
*
* @see java.lang.ref.SoftReference
* @param the type of keys maintained by this map
* @param the type of mapped values
* @author Matthew Wakeling
*/
public abstract class ReferenceMap implements Map
{
private static final Logger LOG = Logger.getLogger(ReferenceMap.class);
protected static final NullValue NULL_VALUE = new NullValue();
protected Map> subMap;
protected ReferenceQueue
© 2015 - 2025 Weber Informatics LLC | Privacy Policy