Package org.a2aproject.sdk.grpc.mapper
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 stateMessage- Full messageTaskStatusUpdateEvent- Status update eventTaskArtifactUpdateEvent- Artifact update event
This mapper provides bidirectional conversion using instanceof checks (toProto) and switch expressions on the oneof case (fromProto).
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault StreamingEventKindfromProto(StreamResponse proto) Converts proto StreamResponse to domain StreamingEventKind.default StreamResponsetoProto(StreamingEventKind domain) Converts domain StreamingEventKind to proto StreamResponse.
-
Field Details
-
INSTANCE
-
-
Method Details
-
toProto
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
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
-