Conversation
|
|
||
| fun addField(field: DtoField) { | ||
| if (field !in fields) fields.add(field) | ||
| lateinit var additionalPropertiesDtoName: String |
There was a problem hiding this comment.
hmmm... having a lateinit public field that is not initialized on construction (ie in an init{} block) might give issues later on.
| } | ||
|
|
||
| private fun addAdditionalProperties(dtoClass: DtoClass, additionalProperties: List<PairGene<Gene, Gene>>) { | ||
| if (additionalProperties.isNotEmpty()) { |
There was a problem hiding this comment.
as a rule of thumb, we should avoid deep nesting. if you have a function, where most/all of its code is inside an if statement, then the condition should be negated and return from function. eg:
if(additionalProperties.isEmpty()) {
return
}
//rest of the code here
this makes code much easier to read
| } | ||
| if (dtoClass.hasAdditionalProperties) { | ||
| lines.indented { | ||
| lines.add("@JsonIgnore") |
There was a problem hiding this comment.
explain in a comment the need for @JsonIgnore here
| } | ||
| if (dtoClass.hasAdditionalProperties) { | ||
| lines.indented { | ||
| lines.add("@JsonAnyGetter") |
There was a problem hiding this comment.
explain in a comment the need for @JsonAnyGetter here
| path.toFile().appendText(testFileContent) | ||
| } | ||
|
|
||
| fun capitalizeFirstChar(word: String) : String { |
There was a problem hiding this comment.
this kind of function should be in a utility class, as can be re-used throughout the codebase. for example, before writing something like this, should check what available in org.evomaster.core.utils... there, you can find StringUtils.capitalization() :)
Adding support for
additionalPropertiescontaining objects. If the target DTO containsadditionalProperties, then the generated DTO will contain code like:Where
ChildSchemais the nested object represented in theadditionalProperties.