• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GENERATED SOURCE. DO NOT MODIFY. */
2 // © 2016 and later: Unicode, Inc. and others.
3 // License & terms of use: http://www.unicode.org/copyright.html#License
4 /*
5 *******************************************************************************
6 *   Copyright (C) 2010, International Business Machines
7 *   Corporation and others.  All Rights Reserved.
8 *******************************************************************************
9 */
10 package ohos.global.icu.impl;
11 
12 /**
13  * Base class for cache implementations.
14  * To use, instantiate a subclass of a concrete implementation class, where the subclass
15  * implements the createInstance() method, and call get() with the key and the data.
16  * The get() call will use the data only if it needs to call createInstance(),
17  * otherwise the data is ignored.
18  *
19  * @param <K> Cache lookup key type
20  * @param <V> Cache instance value type
21  * @param <D> Data type for creating a new instance value
22  *
23  * @author Markus Scherer, Mark Davis
24  * @hide exposed on OHOS
25  */
26 public abstract class CacheBase<K, V, D> {
27     /**
28      * Retrieves an instance from the cache. Calls createInstance(key, data) if the cache
29      * does not already contain an instance with this key.
30      * Ignores data if the cache already contains an instance with this key.
31      * @param key Cache lookup key for the requested instance
32      * @param data Data for createInstance() if the instance is not already cached
33      * @return The requested instance
34      */
getInstance(K key, D data)35     public abstract V getInstance(K key, D data);
36     /**
37      * Creates an instance for the key and data. Must be overridden.
38      * @param key Cache lookup key for the requested instance
39      * @param data Data for the instance creation
40      * @return The requested instance
41      */
createInstance(K key, D data)42     protected abstract V createInstance(K key, D data);
43 }
44