Class Utils_v0_3
java.lang.Object
org.a2aproject.sdk.compat03.util.Utils_v0_3
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:
- JSON serialization via
toJsonString(Object) - Null-safe value defaults via
defaultIfNull(Object, Object) - Artifact streaming support via
appendArtifactToTask(Task_v0_3, TaskArtifactUpdateEvent_v0_3, String)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Task_v0_3appendArtifactToTask(Task_v0_3 task, TaskArtifactUpdateEvent_v0_3 event, String taskId) Appends or updates an artifact in a task based on aTaskArtifactUpdateEvent_v0_3.static <T> TdefaultIfNull(T value, T defaultValue) static StringtoJsonString(Object data)
-
Constructor Details
-
Utils_v0_3
public Utils_v0_3()
-
-
Method Details
-
toJsonString
-
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 aTaskArtifactUpdateEvent_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
appendflag in the event determines the behavior:falseornull: Replace/add the entire artifacttrue: Append the new artifact's parts to an existing artifact with matchingartifactId
- Parameters:
task- the current task to updateevent- the artifact update event containing the new/updated artifacttaskId- the task ID (for logging purposes)- Returns:
- a new Task instance with the updated artifacts list
- See Also:
-