The Java™ transformation generates Java classes from UML model elements. You can use the Java transformation to seed a Java project from UML specifications. You can also apply the Java transformation after the initial seeding to merge updated UML models with existing Java code.
You can generate Java classes from UML models, packages, non-nested classes, and non-nested interfaces. Nested classes and interfaces are generated in the corresponding top level class.
You can apply the Java transformation profile to your model to validate your model for potential transformation problems that cause compilation errors in generated Java code such as, multiple inheritances, circular generalizations, naming conflicts, property conflicts, and private/protected top level classes/interfaces visibility conflicts.
The transformation can generate files in a Java project that has at least one source folder.
You can create a mapping model to specify alternate names for the elements that the transformation generates without modifying the source model. You might want to specify alternate names if you want to include Java-specific details (such as naming restrictions) in platform-independent models, or if the logical organization of the source model is not appropriate as target packaging.
A mapping model is a separate model that has an artifact for each transformable element. Each artifact refers to and has the same name as the original transformable element. You can specify an alternate name by changing the filename property of the artifact.
You can specify a qualified name such as com.ibm.NewName.com or an unqualified name such as NewName. Specifying alternate names for packages, affects all classifiers in that package unless the classifier specifies a fully qualified name. You can also specify alternate locations within the same project for elements that the transformation generates.
After you run the Java transformation, you can make changes to your UML model and run the transformation again. The transformation merges changes to the source model and modified source code by using @generated tags in the Javadocs. The transformation owns Java elements that are marked with @generated and overwrites them during retransformation or deletes them if they were removed from the source model. You can remove the @generated tags from the source code to prevent the transformation from overwriting or deleting the elements.
The transformation can replace the UML model elements of the source model with visual references to generated Java classes. You can then edit the visual reference or make changes to the Java file at the code level. Changes that you make at the visual level are automatically reflected in the Java file. Changes that you make at the code level are reflected in the visual reference.
The UML to Java transformation can create derived relationships from generated Java classes to their UML source model elements.
Related tasks
Generating Java classes from a model
Applying the Java transformation
Related reference
Installed transformations