org.eclipse.internal.xtend.util
Class IdentityCacheWithoutNull<K,V>

java.lang.Object
  extended by org.eclipse.internal.xtend.util.IdentityCacheWithoutNull<K,V>
Type Parameters:
K - The type for the cache's key
V - The type for the cache's value

public abstract class IdentityCacheWithoutNull<K,V>
extends java.lang.Object

This cache treats keys as the same only if they are identical: (key1 == key2) This cache does not store null values, which means that if createNew(key) returns null for a specific key the result is not cached and createNew(key) is called again every time the key's value is requested. Not to cache the null-value provides the advantage that a single lookup in the internal HashMap "get()" is enough to server one request. Otherwise it would be necessary to do a "containsKey()" first and then the "get()" which costs the time of two lookups.

Author:
Moritz Eysholdt

Field Summary
protected  java.util.IdentityHashMap<K,V> internal
           
 
Constructor Summary
IdentityCacheWithoutNull()
           
 
Method Summary
protected abstract  V createNew(K key)
           
 V get(K key)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

internal

protected java.util.IdentityHashMap<K,V> internal
Constructor Detail

IdentityCacheWithoutNull

public IdentityCacheWithoutNull()
Method Detail

createNew

protected abstract V createNew(K key)

get

public V get(K key)