Overview of Java code generation

 

Generating types and accessors

By default, types are generated with their short name (without namespacing). For example, the following diagram:

will lead to the generation of the following code for the association of the "Age" role in the "Person" class :

 

               private Integer age;

 

 

However, it remains possible to generate the association type with its full name by setting the {JavaFullName} tagged value on the navigable association. This way, the following diagram:

 

will lead to the generation of this code :

 

private java.lang.Integer age;

 

 

The above rule applies to the generation of navigable associations, attributes, method parameters, generalizations and implementations.

 

The mapping of types and the generation of accessors is possible using a special package called "JavaTypes".  It is added to the "predefinedTypes" project when Objecteering Java Developer is deployed.

 

A user can therefore modify the mapping of types and the generation of accessors, without having to redefine Objecteering Java Developer:

·         either by modifying the "JavaTypes" package

·         or by creating a similar package and by modifying the "Types translation package" parameter, presented in the parameter connfiguration window.  This parameter designates the package to be used (we recommend this solution).

 

For further details on the structure of the package and the way it is used by the generator, please see "Principles of types and accessor generation".

 

The generation of Java code is based on a UML model, extended by notes and tagged values specific to Java, in order to generate all the code for Java classes.

 

This generation can be parameterized to a high level, using the following mechanisms:

·         Java generation parameters provide general generation options

·         the "JavaTypes" package allows you to set parameters used to generate types of base, accessors, etc

·         the Java "Generation template" allows the integral redefinition of the generation through using Objecteering MDA Modeler

 

 

 

Defining Java annotations

Java annotations are defined in the "Java annotation definition" window (Figure 70).

 

Figure 70. Java annotation definition window

 

This window, accessible by double-clicking on a class stereotyped JavaAnnotation, defines all options available on the annotation definition.

 

Name

Function of the Annotation

Annotation is documented

Specifies whether the annotation is documented. Corresponds to the @Documented annotation type

Annotation is inherited

Specifies whether the annotation is documented. Corresponds to the @Inherited annotation type.

Retention

Specifies the retention policy of the annotation. Corresponds to the @Retention annotation type.

Annotation target

Specifies the types of elements where the annotation is applicable. Corresponds to the @Target annotation type.