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 currentThreadLocalvalue, ornullif not set.key()The key to associate with the ThreadLocal value.voidreset()Remove theThreadLocalvalue.default voidRemove the currentThreadLocalvalue and set the previously stored one.voidSet theThreadLocalvalue.
-
Method Details
-
key
Object key()The key to associate with the ThreadLocal value. This is the key under which the value is saved within aContextSnapshotand the key under which it is looked up. -
getValue
Return the currentThreadLocalvalue, ornullif not set. -
setValue
Set theThreadLocalvalue.- Parameters:
value- the value to set
-
reset
void reset()Remove theThreadLocalvalue. -
restore
Remove the currentThreadLocalvalue and set the previously stored one.- Parameters:
previousValue- previous value to set
-