Interface StreamResponseMapper

All Known Implementing Classes:
StreamResponseMapperImpl

public interface StreamResponseMapper
Mapper between StreamingEventKind and StreamResponse.

StreamResponse uses a protobuf oneof field to represent polymorphic streaming events. StreamingEventKind is a sealed interface with four permitted implementations:

  • Task - Complete task state
  • Message - Full message
  • TaskStatusUpdateEvent - Status update event
  • TaskArtifactUpdateEvent - Artifact update event

This mapper provides bidirectional conversion using instanceof checks (toProto) and switch expressions on the oneof case (fromProto).

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default org.a2aproject.sdk.spec.StreamingEventKind
    Converts proto StreamResponse to domain StreamingEventKind.
    toProto(org.a2aproject.sdk.spec.StreamingEventKind domain)
    Converts domain StreamingEventKind to proto StreamResponse.
  • Field Details

  • Method Details

    • toProto

      default StreamResponse toProto(org.a2aproject.sdk.spec.StreamingEventKind domain)
      Converts domain StreamingEventKind to proto StreamResponse. Uses instanceof checks to determine which oneof field to set.
      Parameters:
      domain - the streaming event kind (Task, Message, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent)
      Returns:
      the proto StreamResponse with the appropriate oneof field set
    • fromProto

      default org.a2aproject.sdk.spec.StreamingEventKind fromProto(StreamResponse proto)
      Converts proto StreamResponse to domain StreamingEventKind. Uses switch expression on the oneof case to determine which type to return.
      Parameters:
      proto - the proto StreamResponse
      Returns:
      the corresponding domain streaming event kind
      Throws:
      IllegalArgumentException - if the oneof field is not set