Record Class FilePart

java.lang.Object
java.lang.Record
org.a2aproject.sdk.spec.FilePart
Record Components:
file - the file content (required, either FileWithBytes or FileWithUri)
metadata - additional metadata for the part
All Implemented Interfaces:
Part<FileContent>

public record FilePart(FileContent file, @Nullable Map<String,Object> metadata) extends Record implements Part<FileContent>
Represents a file content part within a Message or Artifact.

FilePart contains file data that can be provided in two ways:

File parts are used to exchange binary data, documents, images, or any file-based content between users and agents. The choice between bytes and URI depends on file size, accessibility, and security requirements.

Example usage:


 // File with embedded bytes
 FilePart imageBytes = new FilePart(
     new FileWithBytes("image/png", "diagram.png", "iVBORw0KGgoAAAANS...")
 );

 // File with URI reference
 FilePart imageUri = new FilePart(
     new FileWithUri("image/png", "photo.png", "https://example.com/photo.png")
 );
 
See Also:
  • Field Details

    • FILE

      public static final String FILE
      The JSON member name discriminator for file parts: "file".

      In protocol v1.0+, this constant defines the JSON member name used for serialization: { "file": { "mediaType": "image/png", "name": "photo.png", ... } }

      See Also:
  • Constructor Details

    • FilePart

      public FilePart(FileContent file, @Nullable Map<String,Object> metadata)
      Compact constructor with validation.
      Parameters:
      file - the file content (required, either FileWithBytes or FileWithUri)
      Throws:
      IllegalArgumentException - if file is null
    • FilePart

      public FilePart(FileContent file)
      Constructor.
      Parameters:
      file - the file content (required, either FileWithBytes or FileWithUri)
      Throws:
      IllegalArgumentException - if file is null
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • file

      public FileContent file()
      Returns the value of the file record component.
      Returns:
      the value of the file record component
    • metadata

      public @Nullable Map<String,Object> metadata()
      Returns the value of the metadata record component.
      Returns:
      the value of the metadata record component