Package com.ibm.icu.impl
Class CacheBase<K,V,D>
- java.lang.Object
-
- com.ibm.icu.impl.CacheBase<K,V,D>
-
- Type Parameters:
K
- Cache lookup key typeV
- Cache instance value typeD
- Data type for creating a new instance value
- Direct Known Subclasses:
SoftCache
public abstract class CacheBase<K,V,D> extends java.lang.Object
Base class for cache implementations. To use, instantiate a subclass of a concrete implementation class, where the subclass implements the createInstance() method, and call get() with the key and the data. The get() call will use the data only if it needs to call createInstance(), otherwise the data is ignored.
-
-
Constructor Summary
Constructors Constructor Description CacheBase()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description protected abstract V
createInstance(K key, D data)
Creates an instance for the key and data.abstract V
getInstance(K key, D data)
Retrieves an instance from the cache.
-
-
-
Method Detail
-
getInstance
public abstract V getInstance(K key, D data)
Retrieves an instance from the cache. Calls createInstance(key, data) if the cache does not already contain an instance with this key. Ignores data if the cache already contains an instance with this key.- Parameters:
key
- Cache lookup key for the requested instancedata
- Data for createInstance() if the instance is not already cached- Returns:
- The requested instance
-
-