Class Utils_v0_3

java.lang.Object
org.a2aproject.sdk.compat03.util.Utils_v0_3

public class Utils_v0_3 extends Object
Utility class providing common helper methods for A2A Protocol operations.

This class contains static utility methods for JSON serialization/deserialization, null-safe operations, artifact management, and other common tasks used throughout the A2A Java SDK.

Key capabilities:

See Also:
  • Constructor Details

    • Utils_v0_3

      public Utils_v0_3()
  • Method Details

    • toJsonString

      public static String toJsonString(Object data)
    • defaultIfNull

      public static <T> T defaultIfNull(T value, T defaultValue)
    • appendArtifactToTask

      public static Task_v0_3 appendArtifactToTask(Task_v0_3 task, TaskArtifactUpdateEvent_v0_3 event, String taskId)
      Appends or updates an artifact in a task based on a TaskArtifactUpdateEvent_v0_3.

      This method handles streaming artifact updates, supporting both:

      • Adding new artifacts to the task
      • Replacing existing artifacts (when append=false)
      • Appending parts to existing artifacts (when append=true)

      The append flag in the event determines the behavior:

      • false or null: Replace/add the entire artifact
      • true: Append the new artifact's parts to an existing artifact with matching artifactId
      Parameters:
      task - the current task to update
      event - the artifact update event containing the new/updated artifact
      taskId - the task ID (for logging purposes)
      Returns:
      a new Task instance with the updated artifacts list
      See Also: