Package cn.sliew.milky.common.chain
Class ContextMap<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.concurrent.ConcurrentHashMap<K,V>
-
- cn.sliew.milky.common.chain.ContextMap<K,V>
-
- Type Parameters:
K- the type of keys maintained by the context associated with this contextV- the type of mapped values
- All Implemented Interfaces:
Context<K,V>,Serializable,ConcurrentMap<K,V>,Map<K,V>
public class ContextMap<K,V> extends ConcurrentHashMap<K,V> implements Context<K,V>
Convenience base class forContextimplementations.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.concurrent.ConcurrentHashMap
ConcurrentHashMap.KeySetView<K extends Object,V extends Object>
-
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
Constructors Constructor Description ContextMap()Creates a new, empty Context with a default initial capacity, load factor, and concurrencyLevel.ContextMap(int initialCapacity)Creates a new, empty Context with the specified initial capacity, and with default load factor and concurrencyLevelContextMap(int initialCapacity, float loadFactor, int concurrencyLevel)Creates a new, empty Context with the specified initial capacity, load factor, and concurrency level.ContextMap(Logger logger)Creates a new, empty Context with a default initial capacity, load factor, and concurrencyLevel.ContextMap(Map<? extends K,? extends V> t)Creates a new Context with the same mappings as the given map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Loggerlogger()This method provider aLoggerutililies for user can't construct a logger or try to log pipeline context message to one logger file.<T extends V>
Tretrieve(K key)That method enhances theMap.get(Object)method that helps users avoid the redundant code of type cast/checking when assignments are already known.-
Methods inherited from class java.util.concurrent.ConcurrentHashMap
clear, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, forEach, forEach, forEachEntry, forEachEntry, forEachKey, forEachKey, forEachValue, forEachValue, get, getOrDefault, hashCode, isEmpty, keys, keySet, keySet, mappingCount, merge, newKeySet, newKeySet, put, putAll, putIfAbsent, reduce, reduceEntries, reduceEntries, reduceEntriesToDouble, reduceEntriesToInt, reduceEntriesToLong, reduceKeys, reduceKeys, reduceKeysToDouble, reduceKeysToInt, reduceKeysToLong, reduceToDouble, reduceToInt, reduceToLong, reduceValues, reduceValues, reduceValuesToDouble, reduceValuesToInt, reduceValuesToLong, remove, remove, replace, replace, replaceAll, search, searchEntries, searchKeys, searchValues, size, toString, values
-
Methods inherited from class java.util.AbstractMap
clone
-
-
-
-
Field Detail
-
logger
protected Logger logger
-
-
Constructor Detail
-
ContextMap
public ContextMap()
Creates a new, empty Context with a default initial capacity, load factor, and concurrencyLevel.
-
ContextMap
public ContextMap(Logger logger)
Creates a new, empty Context with a default initial capacity, load factor, and concurrencyLevel.
-
ContextMap
public ContextMap(int initialCapacity)
Creates a new, empty Context with the specified initial capacity, and with default load factor and concurrencyLevel- Parameters:
initialCapacity- the initial capacity.
-
ContextMap
public ContextMap(int initialCapacity, float loadFactor, int concurrencyLevel)Creates a new, empty Context with the specified initial capacity, load factor, and concurrency level.- Parameters:
initialCapacity- the initial capacity.loadFactor- the load factor threshold, used to control resizing.concurrencyLevel- the estimated number of concurrently updating threads.
-
-
Method Detail
-
retrieve
public <T extends V> T retrieve(K key)
That method enhances theMap.get(Object)method that helps users avoid the redundant code of type cast/checking when assignments are already known.It throws
ClassCastExceptionif types are not assignable.- Specified by:
retrievein interfaceContext<K,V>- Type Parameters:
T- the target assignment type- Parameters:
key- the key whose associated value is to be returned- Returns:
- the value to which the specified key is mapped,
or
nullif this map contains no mapping for the key - See Also:
Map.get(Object)
-
-