Class MessageMapper

java.lang.Object
ru.yojo.codegen.mapper.AbstractMapper
ru.yojo.codegen.mapper.MessageMapper

public class MessageMapper extends AbstractMapper
Mapper responsible for converting AsyncAPI components.messages definitions into Message objects.

Handles:

  • Polymorphic payloads (oneOf, allOf, anyOf) via deep merging
  • References to schemas ($ref) including inheritance/implementation
  • Leaf scalars/arrays as wrapper DTOs (e.g., payload: string → class with private String payload)
  • Custom generation paths via pathForGenerateMessage
  • Schema cleanup (e.g., removeSchema: true)
  • Validation groups and Lombok overrides per message

Delegates schema-based mapping logic (e.g., field resolution, inner-schema discovery) to SchemaMapper.

  • Constructor Details

    • MessageMapper

      public MessageMapper(SchemaMapper schemaMapper)
      Constructs a new message mapper with the given schema mapper for delegation.
      Parameters:
      schemaMapper - schema mapper to resolve $ref and shared logic
  • Method Details

    • mapMessagesToObjects

      public List<Message> mapMessagesToObjects(ProcessContext processContext)
      Converts all message definitions from the given ProcessContext into Message instances.

      For each message:

      • Initializes message metadata (name, packages, summary)
      • Processes inheritance/implementation directives (extends, implements)
      • Resolves payload structure (polymorphic, reference, inline properties, leaf types)
      • Merges fields from $ref and inline properties without duplication
      • Applies schema removal logic (e.g., via removeSchema: true)
      Parameters:
      processContext - current generation context
      Returns:
      list of fully populated Message objects ready for code generation