Package org.a2aproject.sdk.spec
Interface Part<T>
- Type Parameters:
T- the type of content contained in this part
public interface Part<T>
Base interface for content parts within
Messages and Artifacts.
Parts represent the fundamental content units in the A2A Protocol, allowing multi-modal communication through different content types. A Part can be:
TextPart- Plain text contentFilePart- File content (as bytes or URI reference)DataPart- Structured data (JSON objects)
Parts use polymorphic JSON serialization where the JSON member name itself acts as the type discriminator (e.g., "text", "file", "data"). This aligns with Protocol Buffers' oneof semantics and modern API design practices.
Use instanceof pattern matching to determine the concrete Part type at runtime:
if (part instanceof TextPart textPart) {
String text = textPart.text();
} else if (part instanceof FilePart filePart) {
FileContent file = filePart.file();
}
- See Also: