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 Summary
ConstructorDescriptionMdcPropagationContext
(Map<String, String> state) Creates an instance of aMdcPropagationContext
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.void
restoreThreadContext
(Map<String, String> oldState) Restore the state on the propagation exit.state()
Returns the value of thestate
record component.final String
toString()
Returns a string representation of this record class.Update the thread context on the propagation entry and return the state that will be used for the restore on the propagation exit.
-
Constructor Details
-
MdcPropagationContext
public MdcPropagationContext() -
MdcPropagationContext
Creates an instance of aMdcPropagationContext
record class.- Parameters:
state
- the value for thestate
record component
-
-
Method Details
-
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 interfaceThreadPropagatedContextElement<Map<String,
String>> - Returns:
- The state to be restored
-
restoreThreadContext
Description copied from interface:ThreadPropagatedContextElement
Restore the state on the propagation exit.- Specified by:
restoreThreadContext
in interfaceThreadPropagatedContextElement<Map<String,
String>> - Parameters:
oldState
- The state to be restored
-
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. -
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. -
equals
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 withObjects::equals(Object,Object)
. -
state
Returns the value of thestate
record component.- Returns:
- the value of the
state
record component
-