Record Class CausalContext

java.lang.Object
java.lang.Record
org.j7m.middleware.api.reliability.CausalContext
Record Components:
traceId - causal trace identifier
spanId - current span identifier
parentSpanId - 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 Details

  • Method Details

    • root

      public static CausalContext root()
      Creates a root causal context.
      Returns:
      root context
    • child

      public CausalContext 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:
      true when parent metadata is present
    • 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.
    • traceId

      public String traceId()
      Returns the value of the traceId record component.
      Returns:
      the value of the traceId record component
    • spanId

      public String spanId()
      Returns the value of the spanId record component.
      Returns:
      the value of the spanId record component
    • parentSpanId

      public String parentSpanId()
      Returns the value of the parentSpanId record component.
      Returns:
      the value of the parentSpanId record component