Package ru.yojo.codegen.mapper
Class MessageMapper
java.lang.Object
ru.yojo.codegen.mapper.AbstractMapper
ru.yojo.codegen.mapper.MessageMapper
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 withprivate 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 Summary
ConstructorsConstructorDescriptionMessageMapper(SchemaMapper schemaMapper) Constructs a new message mapper with the given schema mapper for delegation. -
Method Summary
Modifier and TypeMethodDescriptionmapMessagesToObjects(ProcessContext processContext) Converts all message definitions from the givenProcessContextintoMessageinstances.Methods inherited from class ru.yojo.codegen.mapper.AbstractMapper
fillMessageFromChannel, fillProperties, fillRequiredAnnotationsAndImports, fillVariableProperties
-
Constructor Details
-
MessageMapper
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
Converts all message definitions from the givenProcessContextintoMessageinstances.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
$refand inlinepropertieswithout duplication - Applies schema removal logic (e.g., via
removeSchema: true)
- Parameters:
processContext- current generation context- Returns:
- list of fully populated
Messageobjects ready for code generation
-