Package com.atlassian.bamboo.utils.map
Class TypedIdentityMap<V>
java.lang.Object
com.atlassian.bamboo.utils.map.TypedIdentityMap<V>
- Type Parameters:
V- value
- All Implemented Interfaces:
ConcurrentMap<Key<? extends V>,,V> Map<Key<? extends V>,V>
A map which maintains its values type safety through a
References inside the map are automatically garbage collected when the reference to
Key instance without having to cast from Key is lost. See WeakHashMap.
Example:
TypedIdentityMap<Object> map = new TypedIdentityMap<Object>();
Key<Foo> fooKey = Key.create(Foo.class);
map.putIfAbsent(fooKey, new Foo());
Foo foo = map.getValue(fooKey);-
Nested Class Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()boolean<T extends V>
TRetrieves the value represented byKeyin a type safe manner.inthashCode()booleanisEmpty()keySet()voidputIfAbsent(Key<? extends V> key, V value) booleanbooleanintsize()values()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.concurrent.ConcurrentMap
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
-
Constructor Details
-
TypedIdentityMap
public TypedIdentityMap()
-
-
Method Details
-
getValue
Retrieves the value represented byKeyin a type safe manner.- Type Parameters:
T-- Parameters:
key-- Returns:
- value
-
entrySet
-
equals
-
hashCode
public int hashCode() -
putIfAbsent
- Specified by:
putIfAbsentin interfaceConcurrentMap<Key<? extends V>,V> - Specified by:
putIfAbsentin interfaceMap<Key<? extends V>,V>
-
remove
-
replace
-
replace
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKeyin interfaceMap<Key<? extends V>,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<Key<? extends V>,V>
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-