A UML Class can be abstract (isAbstract
attribute),
in which case we want to make the generated Java class abstract as well.
Change the text template contents to:
[#package tutorial.java] [#template public JavaSource(class : uml21.Class)] [#file]generated/${class.name}.java[/#file] public [#if class.isAbstract]abstract [/#if]class ${class.name} { } [/#template]
The "abstract "
static text will be printed only if the condition of the if directive is true.
If you relaunch the generation and open the file NamedElement.java, you see that the NamedElement Java class is now abstract.
public abstract class NamedElement { }
You can compare the generated contents of the file NamedElement.java with the previous generation: