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.Return package, which real generates 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).Returns the Spring Boot version string (e.g.,"3.x.x").booleanbooleanReturns whether@JsonPropertyDescriptionshould be generated.booleanvoidsetCommonPackage(String commonPackage) Sets the package for schema (DTO/enums) classes.voidsetExperimental(boolean experimental) voidsetFilePath(String filePath) Sets the absolute path to the input specification file.voidSets the shared helper instance.voidsetJsonPropertyDescription(boolean jsonPropertyDescription) Enables or disables@JsonPropertyDescriptiongeneration.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) voidsetSpringBootVersion(String springBootVersion) Sets the Spring Boot version.
-
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() -
setExperimental
public void setExperimental(boolean experimental) -
isSplitModels
public boolean isSplitModels() -
setSplitModels
public void setSplitModels(boolean splitModels) -
getHelper
Returns the shared helper instance.- Returns:
- non-null
Helper
-
setHelper
Sets the shared helper instance.- Parameters:
helper- helper to use (must not be null)
-
getSpringBootVersion
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
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;"
-
setJsonPropertyDescription
public void setJsonPropertyDescription(boolean jsonPropertyDescription) Enables or disables@JsonPropertyDescriptiongeneration.- Parameters:
jsonPropertyDescription-trueto generate annotation
-
isJsonPropertyDescription
public boolean isJsonPropertyDescription()Returns whether@JsonPropertyDescriptionshould be generated.- Returns:
trueif enabled
-
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
Return package, which real generates all DTOs. if splitModels == true → return commonPackage. if splitModels == false → return unified package.
-