Hello,
I have some problems with the Code Generation Features of Sparx EA.
First of all, when I transform my model to a Java Model and then generate the java code, Sparx EA seems to get confused with the stereotypes. All of my enumerations have two stereotypes: <<domain-value, enumeration>>, but Sparx EA seems to ignore the second stereotype because it generates simple java classes with getters and setters, not enumerations. If I delete the "domain-value" stereotype, the generation works correctly. Unfortunately, I did not find a way to remove that stereotype in the model-to model transformation. Is it possible to do something like this?
Secondly, I am a little surprised/disappointed by the quality of the generated java code. For example, Sparx EA does not transform the UML type "Real" to something that java understands (e.g. "double"). I added something like
%if type=="Real"%
type="double"
%else%
type=%qt%%CONVERT_TYPE("Java",attType)%%qt%
%endIf%
to the Attribute template, but it seems I need to change more.
Furthermore, I set the collection type to be "Collection<#TYPE#>", but this does not generate the required imports (where do I have to add them?). The generated code also only provides simple setter and getter methods for the whole collection instead of add/remove/contains methods. Is there a way to change the template to create something like this.
All in all, are there "better" templates available somewhere?
Thank you in andvance,
Kind regards,
Nico