Package org.a2aproject.sdk.spec
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:
FileWithBytes- File content embedded as base64-encoded bytesFileWithUri- File content referenced by URI
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFilePart(FileContent file) Constructor.FilePart(FileContent file, @Nullable Map<String, Object> metadata) Compact constructor with validation. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.file()Returns the value of thefilerecord component.final inthashCode()Returns a hash code value for this object.metadata()Returns the value of themetadatarecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
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
Compact constructor with validation.- Parameters:
file- the file content (required, either FileWithBytes or FileWithUri)- Throws:
IllegalArgumentException- if file is null
-
FilePart
Constructor.- Parameters:
file- the file content (required, either FileWithBytes or FileWithUri)- Throws:
IllegalArgumentException- if file is null
-
-
Method Details
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
file
Returns the value of thefilerecord component.- Returns:
- the value of the
filerecord component
-
metadata
Returns the value of themetadatarecord component.- Returns:
- the value of the
metadatarecord component
-