Class AbstractMapper
- Direct Known Subclasses:
MessageMapper,SchemaMapper
Provides reusable methods to:
- Populate
VariablePropertiesfrom raw YAML maps - Handle various field types: primitives, collections, maps, enums, polymorphic schemas, and references
- Apply validation annotations and required imports based on
requiredand format constraints - Resolve inner/anonymous schemas and register them for separate generation
Subclasses SchemaMapper and MessageMapper
extend this to implement schema- and message-specific logic.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidfillMessageFromChannel(Map<String, Object> allContent, Map<String, Object> messagesMap, Set<String> excludeSchemas, Map<String, Object> mapToMessage, String channelName, String channelType) PopulatesmessagesMapfrom AsyncAPI 2.xchannels/publish/subscribesections.voidfillProperties(String schemaName, VariableProperties variableProperties, Map<String, Object> currentSchema, Map<String, Object> schemas, String propertyName, Map<String, Object> propertiesMap, ProcessContext processContext, Map<String, Object> innerSchemas) Populates aVariablePropertiesinstance from a raw YAML property definition.static voidfillRequiredAnnotationsAndImports(VariableProperties variableProperties, Map<String, Object> currentSchema, String propertyName) Applies validation annotations and imports based onrequired, validation groups, and field type.voidfillVariableProperties(String schemaName, VariableProperties variableProperties, Map<String, Object> currentSchema, Map<String, Object> schemas, String propertyName, Map<String, Object> propertiesMap, ProcessContext processContext, Map<String, Object> innerSchemas) Resolves the concrete Java type and metadata for a field based on its raw YAML definition.
-
Constructor Details
-
AbstractMapper
public AbstractMapper()
-
-
Method Details
-
fillProperties
public void fillProperties(String schemaName, VariableProperties variableProperties, Map<String, Object> currentSchema, Map<String, Object> schemas, String propertyName, Map<String, Object> propertiesMap, ProcessContext processContext, Map<String, Object> innerSchemas) Populates aVariablePropertiesinstance from a raw YAML property definition.Sets basic field metadata (name, type, description, example, validation attributes) and delegates detailed type resolution to
fillVariableProperties(java.lang.String, ru.yojo.codegen.domain.VariableProperties, java.util.Map<java.lang.String, java.lang.Object>, java.util.Map<java.lang.String, java.lang.Object>, java.lang.String, java.util.Map<java.lang.String, java.lang.Object>, ru.yojo.codegen.context.ProcessContext, java.util.Map<java.lang.String, java.lang.Object>).- Parameters:
schemaName- name of the containing schema (used for logging and inner schema naming)variableProperties- target field container to populatecurrentSchema- full schema map where this property is definedschemas- global map of all known schemas (for $ref resolution)propertyName- original YAML key (e.g.,"email")propertiesMap- raw YAML map for this field (e.g.,{ type: string, format: email })processContext- current generation context (Spring Boot version, helper, etc.)innerSchemas- accumulator for discovered inner schemas (e.g., anonymous objects, enums)
-
fillVariableProperties
public void fillVariableProperties(String schemaName, VariableProperties variableProperties, Map<String, Object> currentSchema, Map<String, Object> schemas, String propertyName, Map<String, Object> propertiesMap, ProcessContext processContext, Map<String, Object> innerSchemas) Resolves the concrete Java type and metadata for a field based on its raw YAML definition.Handles:
- Maps (
additionalProperties) - Arrays (
type: array) with realization and nested types - References (
$ref) - Plain/inner objects
- Enums
format: existingfor external classes- Polymorphic constructs (
oneOf,allOf,anyOf)
- Parameters:
schemaName- name of the containing schemavariableProperties- field container to populatecurrentSchema- current schema mapschemas- global schema registrypropertyName- field name in YAMLpropertiesMap- raw field definitionprocessContext- generation contextinnerSchemas- accumulator for inner schemas
- Maps (
-
fillMessageFromChannel
public static void fillMessageFromChannel(Map<String, Object> allContent, Map<String, Object> messagesMap, Set<String> excludeSchemas, Map<String, Object> mapToMessage, String channelName, String channelType) PopulatesmessagesMapfrom AsyncAPI 2.xchannels/publish/subscribesections.Resolves payload definitions, extracts polymorphic payloads (e.g.,
oneOf) and creates synthetic message definitions when needed.- Parameters:
allContent- full AsyncAPI documentmessagesMap- output map (schema name → payload)excludeSchemas- set of schema names to exclude from DTO generationmapToMessage- channel operation map (e.g.,subscribeorpublish)channelName- channel keychannelType-"subscribe"or"publish"
-
fillRequiredAnnotationsAndImports
public static void fillRequiredAnnotationsAndImports(VariableProperties variableProperties, Map<String, Object> currentSchema, String propertyName) Applies validation annotations and imports based onrequired, validation groups, and field type.Generates:
@NotNull/@NotBlank/@NotEmptyforrequiredfieldsgroups = {...}variants if validation groups are configured@Validfor nested objects (excluding collections/enums)
- Parameters:
variableProperties- field container (updated in-place)currentSchema- schema map (to readrequired,validationGroups, etc.)propertyName- field name (to check presence inrequired)
-