Interface ThreadLocalAccessor<V>


public interface ThreadLocalAccessor<V>
Contract to assist with access to a ThreadLocal including the ability to get, set, and reset it.
Since:
1.0.0
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Return the current ThreadLocal value, or null if not set.
    key()
    The key to associate with the ThreadLocal value.
    void
    Remove the ThreadLocal value.
    default void
    restore(V previousValue)
    Remove the current ThreadLocal value and set the previously stored one.
    void
    setValue(V value)
    Set the ThreadLocal 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 a ContextSnapshot and the key under which it is looked up.
    • getValue

      @Nullable V getValue()
      Return the current ThreadLocal value, or null if not set.
    • setValue

      void setValue(V value)
      Set the ThreadLocal value.
      Parameters:
      value - the value to set
    • reset

      void reset()
      Remove the ThreadLocal value.
    • restore

      default void restore(V previousValue)
      Remove the current ThreadLocal value and set the previously stored one.
      Parameters:
      previousValue - previous value to set