com.atlassian.bamboo.utils.map
Class TypedIdentityMap<V>

java.lang.Object
  extended by com.atlassian.bamboo.utils.map.TypedIdentityMap<V>
Type Parameters:
V - value
All Implemented Interfaces:
java.util.concurrent.ConcurrentMap<Key<? extends V>,V>, java.util.Map<Key<? extends V>,V>

public class TypedIdentityMap<V>
extends java.lang.Object
implements java.util.concurrent.ConcurrentMap<Key<? extends V>,V>

A map which maintains its values type safety through a instance without having to cast from References inside the map are automatically garbage collected when the reference to Key is lost. See WeakHashMap. Example: TypedIdentityMap map = new TypedIdentityMap(); Key fooKey = Key.create(Foo.class); map.putIfAbsent(fooKey, new Foo()); Foo foo = map.getValue(fooKey);


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
TypedIdentityMap()
           
 
Method Summary
 void clear()
           
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set<java.util.Map.Entry<Key<? extends V>,V>> entrySet()
           
 boolean equals(java.lang.Object o)
           
 V get(java.lang.Object key)
           
<T extends V>
T
getValue(Key<? extends V> key)
          Retrieves the value represented by Key in a type safe manner.
 int hashCode()
           
 boolean isEmpty()
           
 java.util.Set<Key<? extends V>> keySet()
           
 V put(Key<? extends V> key, V value)
           
 void putAll(java.util.Map<? extends Key<? extends V>,? extends V> m)
           
 V putIfAbsent(Key<? extends V> key, V value)
           
 V remove(java.lang.Object key)
           
 boolean remove(java.lang.Object key, java.lang.Object value)
           
 V replace(Key<? extends V> key, V value)
           
 boolean replace(Key<? extends V> key, V oldValue, V newValue)
           
 int size()
           
 java.util.Collection<V> values()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypedIdentityMap

public TypedIdentityMap()
Method Detail

getValue

@Nullable
public <T extends V> T getValue(Key<? extends V> key)
Retrieves the value represented by Key in a type safe manner.

Type Parameters:
T -
Parameters:
key -
Returns:
value

entrySet

public java.util.Set<java.util.Map.Entry<Key<? extends V>,V>> entrySet()
Specified by:
entrySet in interface java.util.Map<Key<? extends V>,V>

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Map<Key<? extends V>,V>
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Map<Key<? extends V>,V>
Overrides:
hashCode in class java.lang.Object

putIfAbsent

public V putIfAbsent(Key<? extends V> key,
                     V value)
Specified by:
putIfAbsent in interface java.util.concurrent.ConcurrentMap<Key<? extends V>,V>

remove

public boolean remove(java.lang.Object key,
                      java.lang.Object value)
Specified by:
remove in interface java.util.concurrent.ConcurrentMap<Key<? extends V>,V>

replace

public boolean replace(Key<? extends V> key,
                       V oldValue,
                       V newValue)
Specified by:
replace in interface java.util.concurrent.ConcurrentMap<Key<? extends V>,V>

replace

public V replace(Key<? extends V> key,
                 V value)
Specified by:
replace in interface java.util.concurrent.ConcurrentMap<Key<? extends V>,V>

size

public int size()
Specified by:
size in interface java.util.Map<Key<? extends V>,V>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map<Key<? extends V>,V>

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map<Key<? extends V>,V>

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map<Key<? extends V>,V>

get

public V get(java.lang.Object key)
Specified by:
get in interface java.util.Map<Key<? extends V>,V>

put

public V put(Key<? extends V> key,
             V value)
Specified by:
put in interface java.util.Map<Key<? extends V>,V>

remove

public V remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map<Key<? extends V>,V>

putAll

public void putAll(java.util.Map<? extends Key<? extends V>,? extends V> m)
Specified by:
putAll in interface java.util.Map<Key<? extends V>,V>

clear

public void clear()
Specified by:
clear in interface java.util.Map<Key<? extends V>,V>

keySet

public java.util.Set<Key<? extends V>> keySet()
Specified by:
keySet in interface java.util.Map<Key<? extends V>,V>

values

public java.util.Collection<V> values()
Specified by:
values in interface java.util.Map<Key<? extends V>,V>


Copyright © 2011 Atlassian. All Rights Reserved.