Interface SecuritySchemeMapper

All Known Implementing Classes:
SecuritySchemeMapperImpl

public interface SecuritySchemeMapper
Mapper between SecurityScheme and SecurityScheme.

This mapper handles the polymorphic sealed interface SecurityScheme by using a custom default method with switch expression. MapStruct doesn't natively support sealed interfaces with protobuf's oneof pattern, so we manually dispatch to the appropriate concrete mapper.

Manual Implementation Required: Must use manual instanceof dispatch to handle sealed interface (5 permitted subtypes) to protobuf oneof pattern, as MapStruct's @SubclassMapping cannot map different source types to different fields of the same target type.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default org.a2aproject.sdk.spec.SecurityScheme
    Converts a protobuf SecurityScheme to domain SecurityScheme.
    toProto(org.a2aproject.sdk.spec.SecurityScheme domain)
    Converts a domain SecurityScheme to protobuf SecurityScheme.
  • Field Details

  • Method Details

    • toProto

      default SecurityScheme toProto(org.a2aproject.sdk.spec.SecurityScheme domain)
      Converts a domain SecurityScheme to protobuf SecurityScheme.

      Uses instanceof checks to handle sealed interface polymorphism, dispatching to the appropriate concrete mapper based on the runtime type. This is necessary because MapStruct cannot automatically handle sealed interfaces with protobuf oneof fields.

      Parameters:
      domain - the domain security scheme (sealed interface)
      Returns:
      the protobuf SecurityScheme with the appropriate oneof field set
    • fromProto

      default org.a2aproject.sdk.spec.SecurityScheme fromProto(SecurityScheme proto)
      Converts a protobuf SecurityScheme to domain SecurityScheme.

      Uses oneof checks to determine which security scheme type is set, dispatching to the appropriate concrete mapper. This reverses the toProto conversion by checking which oneof field is populated.

      Parameters:
      proto - the protobuf SecurityScheme with a oneof field set
      Returns:
      the domain security scheme (sealed interface implementation)