Java transformation profile
Stereotype | Validated source model element |
---|---|
«JavaClass» | Class |
«JavaEnum» | Enumeration |
«JavaEnumConstant» | Enumeration literal |
«JavaField» | Attribute in a class |
«JavaInterface» | Interface |
«JavaMethod» | Operation in a class |
«JavaPackage» | Package |
«JavaParameter» | Input, output, or return parameter |
The UML-to-Java transformation profile also contains stereotypes that the UML-to-Java transformation uses to generate Java code for arrays and collections. These stereotypes are applied automatically when you run the transformation. Applying these stereotypes does not affect modeling activities.
Stereotype | Applicable UML element | Properties | Property description and values | Transformation result |
---|---|---|---|---|
«JavaArray» | Property, parameter | dimensions | Specifies the size of the array Default value is 1 |
Java arrays
of arbitrary dimensions For example, to generate an array of the form int[][], apply the «JavaArray» stereotype to a property or parameter, set the type of the attribute to primitive type int, and set the dimensions value to 2 |
«JavaCollection» | Property or parameter; represents Java collection classes such as Set, List | collectionType | Set to the fully qualified name of the Java collection to generate Default value is java.util.Collection |
Java collection
classes such as Set, or List For example, to generate a map of type Hashmap<String, Object>, you can apply the «JavaCollection» stereotype to a UML property or parameter, set the collectionType to java.util.Hashmap, and set the keyType to java.lang.String |
keyType | Set to the fully qualified name of a key
type used in java.util.Maps Do not specify a value if the collectionType property is not a Java map class No default value |
|||
«JavaRedirect» | Any UML type | redirect | Redirects to any other UML type | The UML to Java transformation will generate all references to the «JavaRedirect» as the redirected type instead. This allows for any type to be specified as a UML template parameter, for the purposes of Java code generation. |
The UML-to-Java transformation profile also contains stereotypes that you can apply to UML elements to model Java generic types.
The following table lists the stereotypes that you can apply to model elements to model Java generics:Stereotype | Applicable UML element |
---|---|
«JavaGenericInstance» | Class |
«JavaWildCard» | TemplateParameterSubstitution
|
«JavaTypeParameter» | TemplateParameter |