2 *******************************************************************************
\r
3 * Copyright (C) 2010, International Business Machines
\r
4 * Corporation and others. All Rights Reserved.
\r
5 *******************************************************************************
\r
7 package com.ibm.icu.impl;
\r
10 * Base class for cache implementations.
\r
11 * To use, instantiate a subclass of a concrete implementation class, where the subclass
\r
12 * implements the createInstance() method, and call get() with the key and the data.
\r
13 * The get() call will use the data only if it needs to call createInstance(),
\r
14 * otherwise the data is ignored.
\r
16 * @param <K> Cache lookup key type
\r
17 * @param <V> Cache instance value type
\r
18 * @param <D> Data type for creating a new instance value
\r
20 * @author Markus Scherer, Mark Davis
\r
22 public abstract class CacheBase<K, V, D> {
\r
24 * Retrieves an instance from the cache. Calls createInstance(key, data) if the cache
\r
25 * does not already contain an instance with this key.
\r
26 * Ignores data if the cache already contains an instance with this key.
\r
27 * @param key Cache lookup key for the requested instance
\r
28 * @param data Data for createInstance() if the instance is not already cached
\r
29 * @return The requested instance
\r
31 public abstract V getInstance(K key, D data);
\r
33 * Creates an instance for the key and data. Must be overridden.
\r
34 * @param key Cache lookup key for the requested instance
\r
35 * @param data Data for the instance creation
\r
36 * @return The requested instance
\r
38 protected abstract V createInstance(K key, D data);
\r