T
- The type of the raw data.K
- The type of key that specifies data.C
- The type of the cache for the raw data.public abstract class CacheMap<T,K,C> extends Object implements Iterable<C>
CacheMap
describes a lazy cache for data indexed by a key.
This class is used to cache YANG data objects in a keyed list. A cache for list element is instantiated on the first access to it.
Modifier | Constructor and Description |
---|---|
protected |
CacheMap(List<T> list)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
Collection<C> |
cachedValues()
Return a collection of cached data.
|
C |
get(K key)
Return the cache for the object associated with the given key.
|
C |
getCached(K key)
Return the cached data associated with the given key.
|
protected abstract K |
getKey(T data)
Return a key in the given raw data.
|
Iterator<C> |
iterator()
Return an iterator over a set of cached data.
|
protected abstract C |
newCache(T data)
Create a new cached data.
|
C |
put(K key,
C value)
Associate the given cache with the given key in this instance.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public final C get(K key)
key
- A key that specifies data.null
if not found.public final C getCached(K key)
key
- A key that specifies data.null
if not cached.public final C put(K key, C value)
key
- A key that specifies data.
Note that the key must be contained in the raw data list
passed to constructor.value
- A new cache for data specified by key
.cache
is returned.public final Collection<C> cachedValues()
protected abstract K getKey(T data)
data
- A raw data.protected abstract C newCache(T data)
data
- A raw data.Copyright © 2018 OpenDaylight. All rights reserved.