Package ru.yojo.codegen.context
Class ProcessContext
java.lang.Object
ru.yojo.codegen.context.ProcessContext
Holds contextual data for a single AsyncAPI specification processing session.
Includes parsed content, configuration, and intermediate state (e.g., resolved schemas/messages).
-
Constructor Summary
ConstructorsConstructorDescriptionProcessContext(Map<String, Object> content) Constructs a new context with the raw parsed YAML content. -
Method Summary
Modifier and TypeMethodDescriptionReturns the package for schema (DTO/enums) classes (e.g.,"com.example.api.common;").Returns the full parsed AsyncAPI document.Returns the package used for generating all DTOs.Returns the absolute path to the input specification file.Returns the shared helper instance.Returns the effective Lombok configuration.Returns the package for message classes (e.g.,"com.example.api.messages;").Returns the map of all message definitions (fromcomponents.messages).Returns the fully qualified class name of the @Nullable annotation to use for non-required fields.Returns the base output directory (without subdirectories like/messages).Returns the base Java package (without.messagesor.common).Returns the final output directory where files will be written (e.g.,".../common/").Returns the map of all schema definitions (fromcomponents.schemas).Deprecated.Returns the validation API namespace to use for generated annotations.booleanReturns whether experimental features are enabled.booleanReturns whether split-model mode is enabled (separate common package).voidsetCommonPackage(String commonPackage) Sets the package for schema (DTO/enums) classes.voidsetExperimental(boolean experimental) Enables or disables experimental features.voidsetFilePath(String filePath) Sets the absolute path to the input specification file.voidsetLombokProperties(LombokProperties lombokProperties) Sets the Lombok configuration to use for generated classes.voidsetMessagePackage(String messagePackage) Sets the package for message classes.voidsetMessagesMap(Map<String, Object> messagesMap) Sets the map of message definitions.voidsetNullableAnnotation(String nullableAnnotation) Sets the fully qualified class name of the @Nullable annotation.voidsetOutputDirectory(String outputDirectory) Sets the base output directory.voidsetPackageLocation(String packageLocation) Sets the base Java package.voidsetPathToWrite(String pathToWrite) Sets the final output directory and ensures it exists.voidsetSchemasMap(Map<String, Object> schemasMap) Sets the map of schema definitions.voidsetSplitModels(boolean splitModels) Enables or disables split-model mode.voidsetSpringBootVersion(String springBootVersion) Deprecated.UsesetValidationApi(ValidationApi)instead.voidsetValidationApi(ValidationApi validationApi) Sets the validation API namespace to use for generated annotations.
-
Constructor Details
-
ProcessContext
Constructs a new context with the raw parsed YAML content.- Parameters:
content- root AsyncAPI document as a Map (e.g., from SnakeYAML)
-
-
Method Details
-
getNullableAnnotation
Returns the fully qualified class name of the @Nullable annotation to use for non-required fields.- Returns:
- nullable annotation FQN or
nullif not configured
-
setNullableAnnotation
Sets the fully qualified class name of the @Nullable annotation.- Parameters:
nullableAnnotation- FQN like "org.jspecify.annotations.Nullable"
-
isExperimental
public boolean isExperimental()Returns whether experimental features are enabled.- Returns:
- true if experimental mode is active
-
setExperimental
public void setExperimental(boolean experimental) Enables or disables experimental features.- Parameters:
experimental- experimental mode flag
-
isSplitModels
public boolean isSplitModels()Returns whether split-model mode is enabled (separate common package).- Returns:
- true if DTOs are split into common package
-
setSplitModels
public void setSplitModels(boolean splitModels) Enables or disables split-model mode.- Parameters:
splitModels- split mode flag
-
getHelper
Returns the shared helper instance.- Returns:
- non-null
Helper
-
getValidationApi
Returns the validation API namespace to use for generated annotations.- Returns:
- validation API (JAVAX or JAKARTA) or
nullif not configured
-
setValidationApi
Sets the validation API namespace to use for generated annotations.When set, this takes precedence over the legacy
springBootVersionfield.- Parameters:
validationApi- JAVAX or JAKARTA
-
getSpringBootVersion
Deprecated.UsegetValidationApi()instead.Returns the Spring Boot version string (e.g.,"3.x.x"). Used to select correct validation annotation packages (jakarta vs javax).- Returns:
- Spring Boot version or
nullif unspecified
-
setSpringBootVersion
Deprecated.UsesetValidationApi(ValidationApi)instead.Sets the Spring Boot version.- Parameters:
springBootVersion- version string (e.g.,"3.x.x")
-
getContent
Returns the full parsed AsyncAPI document.- Returns:
- root YAML content as a
Map
-
getFilePath
Returns the absolute path to the input specification file.- Returns:
- file path or
nullif not set
-
setFilePath
Sets the absolute path to the input specification file.- Parameters:
filePath- absolute path to YAML file
-
getOutputDirectory
Returns the base output directory (without subdirectories like/messages).- Returns:
- base output path
-
setOutputDirectory
Sets the base output directory.- Parameters:
outputDirectory- directory path (e.g.,"src/gen/java/")
-
getPackageLocation
Returns the base Java package (without.messagesor.common).- Returns:
- package (e.g.,
"com.example.api")
-
setPackageLocation
Sets the base Java package.- Parameters:
packageLocation- base package name
-
getLombokProperties
Returns the effective Lombok configuration.- Returns:
- lombok properties
-
setLombokProperties
Sets the Lombok configuration to use for generated classes.- Parameters:
lombokProperties- lombok config
-
getPathToWrite
Returns the final output directory where files will be written (e.g.,".../common/").- Returns:
- absolute path to target directory
-
setPathToWrite
Sets the final output directory and ensures it exists.Does NOT append
/messagesor/common— the caller must provide the full path.- Parameters:
pathToWrite- absolute directory path; ifnull, no-op
-
getMessagePackage
Returns the package for message classes (e.g.,"com.example.api.messages;").If unset, returns
packageLocation + ".messages;".- Returns:
- message package with trailing semicolon
-
setMessagePackage
Sets the package for message classes.- Parameters:
messagePackage- full package, e.g.,"com.example.api.messages;"
-
getCommonPackage
Returns the package for schema (DTO/enums) classes (e.g.,"com.example.api.common;").If unset, returns
packageLocation + ".common;".- Returns:
- schema package with trailing semicolon
-
setCommonPackage
Sets the package for schema (DTO/enums) classes.- Parameters:
commonPackage- full package, e.g.,"com.example.api.common;"
-
getMessagesMap
Returns the map of all message definitions (fromcomponents.messages).- Returns:
- messages map (schema name → definition)
-
setMessagesMap
Sets the map of message definitions.- Parameters:
messagesMap- messages map
-
getSchemasMap
Returns the map of all schema definitions (fromcomponents.schemas).- Returns:
- schemas map (schema name → definition)
-
setSchemasMap
Sets the map of schema definitions.- Parameters:
schemasMap- schemas map
-
getEffectiveCommonPackage
Returns the package used for generating all DTOs. if splitModels == true → return commonPackage. if splitModels == false → return unified package.- Returns:
- effective package string (with trailing semicolon)
-
getValidationApi()instead.