|
TUM CCSM Commons | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.tum.cs.commons.cache.CacheBase<I,H,E,X>
I
- the index type of the cacheH
- the hash map key typeE
- the type stored in the cacheX
- the type of exception thrown by the obtainItem(Object)
method. Use the NeverThrownRuntimeException
if no
exception will be thrown.public abstract class CacheBase<I,H,E,X extends java.lang.Exception>
Common base class for caches. This class basically works like a map that maps
elements of type I
to elements of type E
. As this
class uses a hash map and elements of type I
are not necessarily
suitable as hash map keys a special type (H
) for the hash keys
must be defined. Concrecte keys are determined by method
getHashKey(I)
. Please note that making the hash type explicit as
generic parameter is not due to implementation reasons but to make design
more obvious.
Constructor Summary | |
---|---|
CacheBase()
|
Method Summary | |
---|---|
protected abstract H |
getHashKey(I identifier)
Determine hash key for an identifier. |
abstract E |
getItem(I identifier)
Obtain an item from the cache. |
protected abstract E |
obtainItem(I identifier)
Extenders of the cache class must implemented that method to define the item acquisition mechanism. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CacheBase()
Method Detail |
---|
public abstract E getItem(I identifier) throws X extends java.lang.Exception
identifier
- an object identifying the item to retrieve from the cache.
This class' implementation works with a hash map so
identifiers must adhere to the conventions for
Object.hashcode()
.
X extends java.lang.Exception
protected abstract E obtainItem(I identifier) throws X extends java.lang.Exception
identifier
- identifer unambiguously identifying the item.
X extends java.lang.Exception
protected abstract H getHashKey(I identifier)
identifier
-
Object.hashCode()
|
TUM CCSM Commons | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |