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>
public class TypedIdentityMap<V> extends Object implements ConcurrentMap<Key<? extends V>,V>
A map which maintains its values type safety through aKeyinstance without having to cast fromReferences inside the map are automatically garbage collected when the reference to Keyis lost. SeeWeakHashMap. Example: TypedIdentityMap<Object> map = new TypedIdentityMap<Object>(); Key<Foo> fooKey = Key.create(Foo.class); map.putIfAbsent(fooKey, new Foo()); Foo foo = map.getValue(fooKey);
-
-
Constructor Summary
Constructors Constructor Description TypedIdentityMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<Key<? extends V>,V>>entrySet()booleanequals(Object o)Vget(Object key)<T extends V>
TgetValue(Key<? extends V> key)Retrieves the value represented byKeyin a type safe manner.inthashCode()booleanisEmpty()Set<Key<? extends V>>keySet()Vput(Key<? extends V> key, V value)voidputAll(Map<? extends Key<? extends V>,? extends V> m)VputIfAbsent(Key<? extends V> key, V value)Vremove(Object key)booleanremove(Object key, Object value)Vreplace(Key<? extends V> key, V value)booleanreplace(Key<? extends V> key, V oldValue, V newValue)intsize()Collection<V>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
-
-
-
-
Method Detail
-
getValue
@Nullable public <T extends V> T getValue(Key<? extends V> key)
Retrieves the value represented byKeyin a type safe manner.- Type Parameters:
T-- Parameters:
key-- Returns:
- value
-
equals
public boolean equals(Object o)
-
hashCode
public int hashCode()
-
putIfAbsent
public V putIfAbsent(Key<? extends V> key, V value)
- Specified by:
putIfAbsentin interfaceConcurrentMap<Key<? extends V>,V>- Specified by:
putIfAbsentin interfaceMap<Key<? extends V>,V>
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<Key<? extends V>,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<Key<? extends V>,V>
-
-