com.rubecula.darwin.domain.helper
Class Cache_<K extends net.sf.tostring0.Identifiable,V>
java.lang.Object
com.rubecula.darwin.domain.helper.Cache_<K,V>
- Type Parameters:
K - the unique key type which will be used for this cache.V - the value that will be stored for the given key.
- All Implemented Interfaces:
- Cache, Cache_MBean, net.sf.tostring0.Identifiable
- Direct Known Subclasses:
- FitnessCache, PhenotypeCache
public abstract class Cache_<K extends net.sf.tostring0.Identifiable,V>
- extends java.lang.Object
- implements Cache, net.sf.tostring0.Identifiable
Abstract base class for implementing a Cache.
TODO consider moving this to the foundation package (along with other
Cache-related classes)
TODO consider having K extend CacheSignature instead of
Identifiable.
Essentially, we will delegate the real work to HashMap. Note that it
is required that the type K has an appropriate definition of
Object.hashCode() (and of course equals) so that the cache will
operate the way you expect.
- Author:
- Robin Hillyard
|
Field Summary |
protected static org.apache.commons.logging.Log |
LOG
The logger for this class. |
|
Constructor Summary |
protected |
Cache_()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface net.sf.tostring0.Identifiable |
getIdentifier |
LOG
protected static final org.apache.commons.logging.Log LOG
- The logger for this class.
Cache_
protected Cache_()
count
public int count()
- Specified by:
count in interface Cache_MBean
- Returns:
- the number of entries in the cache
- See Also:
Map.size()
flush
public void flush()
- Does nothing if
_cache is already clear.
- Specified by:
flush in interface Cache
- See Also:
Map.clear()
isActive
public boolean isActive()
- Specified by:
isActive in interface Cache_MBean
- Returns:
- the value of the field
active.
setActive
public void setActive(boolean active)
- Specified by:
setActive in interface Cache_MBean
- Parameters:
active -
add
protected void add(K key,
V value)
- Parameters:
key - value - - See Also:
Map.put(java.lang.Object, java.lang.Object)
cached
protected boolean cached(K key)
- Parameters:
key -
- Returns:
- true if the cache already contains the given key
- See Also:
Map.containsKey(java.lang.Object)
flush
protected void flush(K key)
- Parameters:
key - - See Also:
Map.remove(java.lang.Object)
get
protected V get(K key)
- Parameters:
key -
- Returns:
- the value for this key, if any
- See Also:
Map.get(java.lang.Object)
Copyright © 2010 Rubecula Software, LLC. All Rights Reserved.