'customize the variable assignment in openapi generated java code
I am generating java code from the openapi specification file using spring-boot generator. In generated java class I have some containers generated as below:
private final List<Cat> links = null;
private final Map<String, Pet> dataTypes = null;
private final List<String> create = null;
I want assignment these containers to some implementations as below:
private final List<Cat> links = new ArrayList<>();
private final Map<String, Pet> dataTypes = new TreeMap<>();
private final List<String> create = new LinkedList<>();
with below changes in pojo.mustache, I am able to assign all 3 above variables to some one type of implementations like TreeMap. But not able to assign different implementations to different types of variables as mentioned above.
private final {{>nullableDataType}} {{name}} = {{#required}}{{{defaultValue}}}{{/required}}{{^required}}new TreeMap<>(){{/required}};
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
