Class ArtifactUtils

java.lang.Object
org.a2aproject.sdk.server.util.ArtifactUtils

public final class ArtifactUtils extends Object
Utility functions for creating A2A Artifact objects.
  • Method Details

    • newArtifact

      public static Artifact newArtifact(String name, List<Part<?>> parts, @Nullable String description)
      Creates a new Artifact object.
      Parameters:
      name - The human-readable name of the artifact.
      parts - The list of Part objects forming the artifact's content.
      description - An optional description of the artifact.
      Returns:
      A new Artifact object with a generated artifact_id.
    • newArtifact

      public static Artifact newArtifact(String name, List<Part<?>> parts)
      Creates a new Artifact object with empty description.
      Parameters:
      name - The human-readable name of the artifact.
      parts - The list of Part objects forming the artifact's content.
      Returns:
      A new Artifact object with a generated artifact_id.
    • newTextArtifact

      public static Artifact newTextArtifact(String name, String text, @Nullable String description)
      Creates a new Artifact object containing only a single TextPart.
      Parameters:
      name - The human-readable name of the artifact.
      text - The text content of the artifact.
      description - An optional description of the artifact.
      Returns:
      A new Artifact object with a generated artifact_id.
    • newTextArtifact

      public static Artifact newTextArtifact(String name, String text)
      Creates a new Artifact object containing only a single TextPart with empty description.
      Parameters:
      name - The human-readable name of the artifact.
      text - The text content of the artifact.
      Returns:
      A new Artifact object with a generated artifact_id.
    • newDataArtifact

      public static Artifact newDataArtifact(String name, Object data, @Nullable String description)
      Creates a new Artifact object containing only a single DataPart.

      Supports any JSON value type: objects (Map), arrays (List), primitives (String, Number, Boolean), or null.

      Parameters:
      name - The human-readable name of the artifact.
      data - The structured data content of the artifact (JSON object, array, primitive, or null).
      description - An optional description of the artifact.
      Returns:
      A new Artifact object with a generated artifact_id.
    • newDataArtifact

      public static Artifact newDataArtifact(String name, Object data)
      Creates a new Artifact object containing only a single DataPart with empty description.

      Supports any JSON value type: objects (Map), arrays (List), primitives (String, Number, Boolean), or null.

      Parameters:
      name - The human-readable name of the artifact.
      data - The structured data content of the artifact (JSON object, array, primitive, or null).
      Returns:
      A new Artifact object with a generated artifact_id.