Record Class CausalContext
java.lang.Object
java.lang.Record
org.j7m.middleware.api.reliability.CausalContext
- Record Components:
traceId- causal trace identifierspanId- current span identifierparentSpanId- parent span identifier, or empty for a root context
- All Implemented Interfaces:
Serializable
public record CausalContext(String traceId, String spanId, String parentSpanId)
extends Record
implements Serializable
Causal relationship metadata for root and child invocations.
The record is immutable, serializable, and thread-safe. It contains only stable identifiers, not payload data.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCausalContext(String traceId, String spanId, String parentSpanId) Creates a validated causal context. -
Method Summary
Modifier and TypeMethodDescriptionchild()Creates a child causal context under this context.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanReports whether this context has a parent span.Returns the value of theparentSpanIdrecord component.static CausalContextroot()Creates a root causal context.spanId()Returns the value of thespanIdrecord component.final StringtoString()Returns a string representation of this record class.traceId()Returns the value of thetraceIdrecord component.
-
Constructor Details
-
CausalContext
Creates a validated causal context.- Throws:
IllegalArgumentException- when an identifier is invalid
-
-
Method Details
-
root
-
child
Creates a child causal context under this context.- Returns:
- child context
-
hasParent
public boolean hasParent()Reports whether this context has a parent span.- Returns:
truewhen parent metadata is present
-
toString
-
hashCode
-
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). -
traceId
-
spanId
-
parentSpanId
Returns the value of theparentSpanIdrecord component.- Returns:
- the value of the
parentSpanIdrecord component
-