The following table lists how the transformations transform UML elements into Java elements.
| UML element | Java element |
|---|---|
| Package | Java package with the same name |
| Package with the «perspective» stereotype | Ignored |
| Package with the «analysis» or «Analysis» keyword | Ignored |
| Class | Java class with the same name and visibility |
| Class with an Is Leaf property | Java class is final if true |
| Class with an Is Abstract property | Java class is abstract if true |
| Class with a generalization relationship | Java class extends the specified superclass |
| Interface realization or Realization relationship between a class and an interface | Java class implements the specified interface |
| Interface | Java interface with the same name and visibility |
| Interface with a generalization relationship | Java interface extends the specified interface |
| Enumeration | Java enumeration If the transformation is not configured to generate code that is compatible with J2SE 5.0, the transformation generates a Java interface with the same name and visibility. |
| Enumeration literal | Enumerator |
| Operation | Java method with the same name and visibility |
| Operation with an Is Static property | Java method is static if true |
| Operation with an Is Abstract property | Java method is abstract if true |
| Operation with an Is Leaf property | Java method is final if true |
| Operation with the same name as its class | Java constructor |
| Operation with the «create» stereotype | Java constructor |
| Operation with one or more UML classes specified in the RaisedException property | Java throws statement followed by the list of throwable classes |
| Parameter | Java parameter with the same name |
| Parameter with a type property | Java parameter has the specified type, which can be another class or a primitive type |
| Parameter with a direction property | Java method
has a return <param type> if it is set to return Java method with <param type> <param name> in its method signature if it is not set to return |
| Parameter or property with multiplicities: | |
| 0..1 | Attribute or reference |
| 1 | Attribute |
| N (N>1) | Array |
| x..* (for example, 1..*), *, or x..y | See the following table. In a list of operation parameters, if the last operation parameter has multiplicity of * or x..*, it is transformed into a Java vararg (variable arity argument, which is indicated by an ellipsis after the type). If the operation parameter has multiplicity x..y, it is transformed into an array. |
| Property | Java field with the same name and visibility |
| Property with an Is Static property | Java field is static if true |
| Property with an Is Leaf property | Java field is final if true |
| Property with a type property | Java field has the specified type, which can be another class or a primitive type |
The following table lists how the transformations process parameters and properties with multiplicity x..*, *, or x..y. When you create or configure a UML-to-Java transformation configuration, you can specify that the transformation generate a different Java collection type. The Java collection type defined in the UML-to-Java transformation configuration is applied to all parameters except the last one. To transform the last parameter that has multiplicity x..*, *, or x..y into a Java collection, you must apply the «JavaCollection» stereotype to the corresponding UML parameter or property, and set the collectionType property of the stereotype.
| isOrdered property | isUnique property | UML collection | Generated Java type |
|---|---|---|---|
| true | true | Ordered set | java.util.SortedSet |
| true | false | Sequence | java.util.List |
| false | true | Set | java.util.Set |
| false | false | Bag | java.util.Collection |
/* * <!-- begin-UML-doc --> * <!-- end-UML-doc --> */