Class Artifact.Builder

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

public static class Artifact.Builder extends Object
Builder for constructing immutable Artifact instances.

The Builder provides a fluent API for creating artifacts with required and optional fields. Artifacts must have an artifactId and non-empty parts list.

Example usage:


 Artifact result = Artifact.builder()
     .artifactId("artifact-123")
     .name("Analysis Report")
     .description("Detailed analysis of user data")
     .parts(List.of(new TextPart("Report content...", null)))
     .build();
 
  • Method Details

    • artifactId

      public Artifact.Builder artifactId(String artifactId)
      Sets the unique identifier for this artifact.
      Parameters:
      artifactId - the artifact identifier (required)
      Returns:
      this builder for method chaining
    • name

      public Artifact.Builder name(@Nullable String name)
      Sets the human-readable name of the artifact.
      Parameters:
      name - the artifact name (optional)
      Returns:
      this builder for method chaining
    • description

      public Artifact.Builder description(@Nullable String description)
      Sets a brief description of the artifact's purpose or content.
      Parameters:
      description - the artifact description (optional)
      Returns:
      this builder for method chaining
    • parts

      public Artifact.Builder parts(List<Part<?>> parts)
      Sets the content parts comprising the artifact.
      Parameters:
      parts - the list of content parts (required, must not be empty)
      Returns:
      this builder for method chaining
    • parts

      public Artifact.Builder parts(Part<?>... parts)
      Sets the content parts from varargs.
      Parameters:
      parts - the content parts (required, must not be empty)
      Returns:
      this builder for method chaining
    • metadata

      public Artifact.Builder metadata(@Nullable Map<String,Object> metadata)
      Sets additional metadata for the artifact.
      Parameters:
      metadata - map of metadata key-value pairs (optional)
      Returns:
      this builder for method chaining
    • extensions

      public Artifact.Builder extensions(@Nullable List<String> extensions)
      Sets the list of protocol extensions used in this artifact.
      Parameters:
      extensions - the list of extension identifiers (optional)
      Returns:
      this builder for method chaining
    • build

      public Artifact build()
      Builds a new immutable Artifact from the current builder state.
      Returns:
      a new Artifact instance
      Throws:
      IllegalArgumentException - if required fields are missing or parts is empty