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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
boolean
<T extends V>
TRetrieves the value represented byKey
in a type safe manner.int
hashCode()
boolean
isEmpty()
keySet()
void
putIfAbsent
(Key<? extends V> key, V value) boolean
boolean
int
size()
values()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods 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 byKey
in a type safe manner.- Type Parameters:
T
-- Parameters:
key
-- Returns:
- value
-
entrySet
-
equals
-
hashCode
public int hashCode() -
putIfAbsent
- Specified by:
putIfAbsent
in interfaceConcurrentMap<Key<? extends V>,
V> - Specified by:
putIfAbsent
in interfaceMap<Key<? extends V>,
V>
-
remove
-
replace
-
replace
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<Key<? extends V>,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<Key<? extends V>,
V>
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-