Package io.micrometer.context
Interface ThreadLocalAccessor<V>
public interface ThreadLocalAccessor<V>
Contract to assist with access to a
ThreadLocal
including the ability to get,
set, and reset it.-
Method Summary
Modifier and TypeMethodDescriptiongetValue()
Return the currentThreadLocal
value, ornull
if not set.key()
The key to associate with the ThreadLocal value.void
reset()
Remove theThreadLocal
value.default void
Remove the currentThreadLocal
value and set the previously stored one.void
Set theThreadLocal
value.
-
Method Details
-
key
Object key()The key to associate with the ThreadLocal value. This is the key under which the value is saved within aContextSnapshot
and the key under which it is looked up. -
getValue
Return the currentThreadLocal
value, ornull
if not set. -
setValue
Set theThreadLocal
value.- Parameters:
value
- the value to set
-
reset
void reset()Remove theThreadLocal
value. -
restore
Remove the currentThreadLocal
value and set the previously stored one.- Parameters:
previousValue
- previous value to set
-