Modelio Java Architect allows you to create Stereotypes that represent java annotations.

Java Architect represents Java annotations by default with a "JavaAnnotation" note.

Creating an annotation stereotype

  1. Go to the "module LocalModule" module

  2. Create a profile profile

  3. Create a stereotypestereotype .

    In the stereotype dialog box:

    1. Give as name the simple name of the java annotation you want to represent

    2. Select as metaclass the metaclass the java annotation applies to.

      • For a java annotation that applies to types, choose Standard.Classifier.

      • For a java annotation that applies to members, choose Standard.StructuralFeature.

      • For a java annotation that applies to parameters, choose Standard.Parameter.

    3. you may choose an icon and an image

Note

If the java annotation applies to many targets you may have to create many Stereotypes.

Java annotation mappings

Once the stereotype is created the java annotation type is represented in Modelio by many elements:

  1. a "javaannotation JavaAnnotation" stereotyped class

  2. The stereotypestereotype(s) you created

Using the stereotype

You may either :

  • Add the annotation in the generated file then reverse it.

    The stereotype will be applied automatically.

  • apply the created stereotype on an element then generate the Java code.

    In this case you will have to add manually an ElementImport toward the "JavaAnnotation" stereotyped class.

Limitations

  • Java Architect does not support java annotations with the same simple name in different packages.

  • When applying manually a java annotation stereotype, the generated java file misses an import clause toward the java annotation type. It is recommended instead to add the java annotation in the java file first before reversing it.