Record Class MdcPropagationContext

java.lang.Object
java.lang.Record
io.micronaut.context.propagation.slf4j.MdcPropagationContext
Record Components:
state - The MDC state as map
All Implemented Interfaces:
PropagatedContextElement, ThreadPropagatedContextElement<Map<String,String>>

public record MdcPropagationContext(Map<String,String> state) extends Record implements ThreadPropagatedContextElement<Map<String,String>>
MDC propagation.
Since:
4.0.0
Author:
Denis Stepanov
  • Constructor Details

    • MdcPropagationContext

      public MdcPropagationContext()
    • MdcPropagationContext

      public MdcPropagationContext(Map<String,String> state)
      Creates an instance of a MdcPropagationContext record class.
      Parameters:
      state - the value for the state record component
  • Method Details

    • updateThreadContext

      public Map<String,String> updateThreadContext()
      Description copied from interface: ThreadPropagatedContextElement
      Update the thread context on the propagation entry and return the state that will be used for the restore on the propagation exit.
      Specified by:
      updateThreadContext in interface ThreadPropagatedContextElement<Map<String,String>>
      Returns:
      The state to be restored
    • restoreThreadContext

      public void restoreThreadContext(Map<String,String> oldState)
      Description copied from interface: ThreadPropagatedContextElement
      Restore the state on the propagation exit.
      Specified by:
      restoreThreadContext in interface ThreadPropagatedContextElement<Map<String,String>>
      Parameters:
      oldState - The state to be restored
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • state

      public Map<String,String> state()
      Returns the value of the state record component.
      Returns:
      the value of the state record component