Hello world tutorial in java

Design a simple UML model

Let's create 3 simple classes. I'll generate the code in Java language as it is the one I know best :

Create one java template

Now, let's code your first template, made of 2 files :

tutorial-name.mda

${targetDir}/${c.getFullyQualifiedName("/")}.java
				

tutorial-content.mda:

package ${c.owner.getFullyQualifiedName(".")};
/**
* This class was generated automatically thanks to any

*/
public class ${c.name} {
	<% c.attributes.each { %>
		${java.attribute(it)}
	<% } %>
	
	<% c.attributes.each { %>
		${java.getter(it)}
	<% } %>
	
	<% c.attributes.each { %>
		${java.setter(it)}
	<% } %>
}
				

You may have noticed 'java' variable. This is a built-in directive . Because Anycode UML API can sometimes be difficult to use, boilerplate code is added to directives so that you only have to focus on your custom code generation.

Generate your java code

Once both files are saved in a directory (let's say "template" directory), you can call the plugin, as shown below :

Finally, look at the target directory. Done !