Class ManagedIdentityConcurrentMap<K,V>

java.lang.Object
java.util.AbstractMap<K,V>
org.apache.groovy.util.concurrent.ConcurrentReferenceHashMap<K,V>
org.apache.groovy.util.concurrent.ManagedIdentityConcurrentMap<K,V>
Type Parameters:
K - the key type
V - the value type
All Implemented Interfaces:
Serializable, Map<K,V>

public class ManagedIdentityConcurrentMap<K,V> extends ConcurrentReferenceHashMap<K,V>
This is a basic implementation of a map able to forget its keys could be weak/soft/strong references. This bases on ConcurrentReferenceHashMap, thus it is safe for concurrency. This map compares keys through references.
Since:
4.0.0
See Also:
  • Constructor Details

    • ManagedIdentityConcurrentMap

      public ManagedIdentityConcurrentMap()
      Creates a new, empty map with the key weak reference
    • ManagedIdentityConcurrentMap

      public ManagedIdentityConcurrentMap(int initialCapacity)
      Creates a new, empty map with the key weak reference and the specified initial capacity
      Parameters:
      initialCapacity - initial capacity
    • ManagedIdentityConcurrentMap

      public ManagedIdentityConcurrentMap(ConcurrentReferenceHashMap.ReferenceType keyType)
      Creates a new, empty map with the specified key reference type
      Parameters:
      keyType - key reference type
    • ManagedIdentityConcurrentMap

      public ManagedIdentityConcurrentMap(ConcurrentReferenceHashMap.ReferenceType keyType, int initialCapacity)
      Creates a new, empty map with the specified key reference type and initial capacity
      Parameters:
      keyType - key reference type
      initialCapacity - the initial capacity
  • Method Details

    • getOrPut

      public V getOrPut(K key, V value)
      Get the key specified value, or put the default value and return it if the key is absent
      Parameters:
      key - the key to look up
      value - the default value if the key is absent
      Returns:
      the value