Interface PartMapper

All Known Implementing Classes:
PartMapperImpl

public interface PartMapper
Mapper between Part and Part.

Handles polymorphic Part conversion using the proto's oneof content field:

  • TextPart - maps to Part.text
  • FilePart(FileWithBytes) - maps to Part.raw + Part.filename + Part.media_type
  • FilePart(FileWithUri) - maps to Part.url + Part.filename + Part.media_type
  • DataPart - maps to Part.data (google.protobuf.Value containing any JSON value: object, array, primitive, or null)

Manual Implementation Required: Must use manual instanceof dispatch to handle protobuf oneof pattern, as MapStruct's @SubclassMapping maps to different target types, not different fields of the same type.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final PartMapper
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default Part<?>
    fromProto(Part proto)
    Converts proto Part to domain Part.
    default Part
    toProto(Part<?> domain)
    Converts domain Part to proto Part.
  • Field Details

  • Method Details

    • toProto

      default Part toProto(Part<?> domain)
      Converts domain Part to proto Part. Handles TextPart, FilePart (FileWithBytes and FileWithUri), and DataPart polymorphism.
    • fromProto

      default Part<?> fromProto(Part proto)
      Converts proto Part to domain Part. Reconstructs TextPart, FilePart, or DataPart based on oneof content field.