Class TaskArtifactUpdateEvent.Builder

java.lang.Object
org.a2aproject.sdk.spec.TaskArtifactUpdateEvent.Builder
Enclosing class:
TaskArtifactUpdateEvent

public static class TaskArtifactUpdateEvent.Builder extends Object
Builder for constructing TaskArtifactUpdateEvent instances.

Example for complete artifact:


 TaskArtifactUpdateEvent event = TaskArtifactUpdateEvent.builder()
     .taskId("task-123")
     .contextId("ctx-456")
     .artifact(new Artifact.Builder()
         .artifactId("artifact-789")
         .parts(List.of(new TextPart("Analysis complete")))
         .build())
     .build();
 

Example for incremental chunk:


 TaskArtifactUpdateEvent chunk = TaskArtifactUpdateEvent.builder()
     .taskId("task-123")
     .contextId("ctx-456")
     .artifact(new Artifact.Builder()
         .artifactId("artifact-789")
         .parts(List.of(new TextPart("more text...")))
         .build())
     .append(true)
     .lastChunk(false)
     .build();
 
  • Method Details

    • taskId

      public TaskArtifactUpdateEvent.Builder taskId(String taskId)
      Sets the task identifier.
      Parameters:
      taskId - the task ID (required)
      Returns:
      this builder for method chaining
    • artifact

      public TaskArtifactUpdateEvent.Builder artifact(Artifact artifact)
      Sets the artifact being updated.
      Parameters:
      artifact - the artifact (required)
      Returns:
      this builder for method chaining
    • contextId

      public TaskArtifactUpdateEvent.Builder contextId(String contextId)
      Sets the context identifier.
      Parameters:
      contextId - the context ID (required)
      Returns:
      this builder for method chaining
    • append

      public TaskArtifactUpdateEvent.Builder append(@Nullable Boolean append)
      Sets whether this update should append to an existing artifact.
      Parameters:
      append - true to append, false or null for new artifact
      Returns:
      this builder for method chaining
    • lastChunk

      public TaskArtifactUpdateEvent.Builder lastChunk(@Nullable Boolean lastChunk)
      Sets whether this is the final chunk for the artifact.
      Parameters:
      lastChunk - true if final chunk, false or null otherwise
      Returns:
      this builder for method chaining
    • metadata

      public TaskArtifactUpdateEvent.Builder metadata(Map<String,Object> metadata)
      Sets the metadata for this event.
      Parameters:
      metadata - map of metadata key-value pairs (optional)
      Returns:
      this builder for method chaining
    • build

      public TaskArtifactUpdateEvent build()
      Builds the TaskArtifactUpdateEvent.
      Returns:
      a new TaskArtifactUpdateEvent instance
      Throws:
      IllegalArgumentException - if required fields are missing