Package org.mockserver.collections
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>
- Author:
- jamesdbloom
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
ConstructorsConstructorDescriptionCircularHashMap(int maxSize) CircularHashMap(int maxSize, Consumer<V> evictionListener) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanremoveEldestEntry(Map.Entry<K, V> eldest) voidsetMaxSize(int maxSize) Resize the bound.Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, valuesMethods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeMethods inherited from class java.util.AbstractMap
equals, hashCode, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
Constructor Details
-
CircularHashMap
public CircularHashMap(int maxSize) -
CircularHashMap
-
-
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 nextput. This lets a livemaxExpectationschange viaPUT /mockserver/configurationresize 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
RequestMatchersdoes; theLocalCallbackRegistrymaps are wrapped inCollections.synchronizedMap). -
removeEldestEntry
- Overrides:
removeEldestEntryin classLinkedHashMap<K,V>
-
findKey
-