Class CircularHashMap<K,V>

java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<K,V>
org.mockserver.collections.CircularHashMap<K,V>
All Implemented Interfaces:
Serializable, Cloneable, Map<K,V>

public class CircularHashMap<K,V> extends LinkedHashMap<K,V>
Author:
jamesdbloom
See Also:
  • Constructor Details

    • CircularHashMap

      public CircularHashMap(int maxSize)
    • CircularHashMap

      public CircularHashMap(int maxSize, Consumer<V> evictionListener)
  • Method Details

    • setMaxSize

      public void setMaxSize(int maxSize)
      Resize the bound. A SHRINK takes effect immediately: the eldest entries are removed (firing the eviction listener, exactly as an overflow eviction would) until the map fits the new bound, rather than waiting for the next put. This lets a live maxExpectations change via PUT /mockserver/configuration resize this map alongside the expectation queue it shadows.

      Not internally synchronized — callers that share the map across threads must serialize this with their other mutations (MockServer's RequestMatchers does; the LocalCallbackRegistry maps are wrapped in Collections.synchronizedMap).

    • removeEldestEntry

      protected boolean removeEldestEntry(Map.Entry<K,V> eldest)
      Overrides:
      removeEldestEntry in class LinkedHashMap<K,V>
    • findKey

      public K findKey(V value)