Class Cache.RefConcurrentMap<K,V>

java.lang.Object
org.apache.maven.impl.cache.Cache.RefConcurrentMap<K,V>
Type Parameters:
K - the type of keys maintained by this map
V - the type of mapped values
All Implemented Interfaces:
Map<K,V>, Cache<K,V>
Enclosing interface:
Cache<K,V>

public static class Cache.RefConcurrentMap<K,V> extends Object implements Map<K,V>, Cache<K,V>
A concurrent map implementation that uses configurable reference types for both keys and values, and supports automatic cleanup of garbage-collected entries.

This implementation is package-private and accessed through the Cache interface.

  • Method Details

    • setEvictionListener

      public void setEvictionListener(Cache.EvictionListener listener)
      Sets an eviction listener to be notified of eviction events.
    • computeIfAbsent

      public V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
      Specified by:
      computeIfAbsent in interface Cache<K,V>
      Specified by:
      computeIfAbsent in interface Map<K,V>
    • computeIfAbsent

      public V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction, Cache.ReferenceType referenceType)
      Computes a value for the given key if it's not already present, using the specified reference type.

      This method allows fine-grained control over the reference type used for individual entries, overriding the map's default reference type for this specific key-value pair.

      Specified by:
      computeIfAbsent in interface Cache<K,V>
      Parameters:
      key - the key whose associated value is to be returned or computed
      mappingFunction - the function to compute a value
      referenceType - the reference type to use for this entry (null uses map default)
      Returns:
      the current (existing or computed) value associated with the specified key
    • size

      public int size()
      Specified by:
      size in interface Cache<K,V>
      Specified by:
      size in interface Map<K,V>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<K,V>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Cache<K,V>
      Specified by:
      containsKey in interface Map<K,V>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<K,V>
    • get

      public V get(Object key)
      Specified by:
      get in interface Cache<K,V>
      Specified by:
      get in interface Map<K,V>
    • put

      public V put(K key, V value)
      Specified by:
      put in interface Map<K,V>
    • remove

      public V remove(Object key)
      Specified by:
      remove in interface Map<K,V>
    • removeIf

      public void removeIf(BiPredicate<K,V> filter)
      Specified by:
      removeIf in interface Cache<K,V>
    • putAll

      public void putAll(Map<? extends K,? extends V> m)
      Specified by:
      putAll in interface Map<K,V>
    • clear

      public void clear()
      Specified by:
      clear in interface Cache<K,V>
      Specified by:
      clear in interface Map<K,V>
    • keySet

      public Set<K> keySet()
      Specified by:
      keySet in interface Map<K,V>
    • values

      public Collection<V> values()
      Specified by:
      values in interface Map<K,V>
    • entrySet

      public Set<Map.Entry<K,V>> entrySet()
      Specified by:
      entrySet in interface Map<K,V>
    • getKeyReferenceType

      public Cache.ReferenceType getKeyReferenceType()
      Returns the key reference type used by this cache.
    • getValueReferenceType

      public Cache.ReferenceType getValueReferenceType()
      Returns the value reference type used by this cache.
    • getReferenceTypeKey

      public String getReferenceTypeKey()
      Returns a string representation of the reference type combination.
    • getName

      public String getName()
      Returns the cache name for debugging purposes.