The UML-to-Java transformation generates Java™ classes from Unified Modeling Language (UML) model elements. You can use this transformation to seed a Java project from UML specifications. You can also apply the UML-to-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, non-nested interfaces, and enumerations. For models, packages, classes, and interfaces, the transformation also processes the contents of these elements. For example, when the transformation processes a class, the transformation also processes the operations and properties of the class.
You can apply the UML-to-Java transformation profile to your model to validate your model for potential transformation problems that cause compilation errors in generated Java code. The validation process checks for problems such as multiple inheritances, circular generalizations, naming conflicts, property conflicts, and visibility conflicts of private or protected top-level classes and interfaces.
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.
You can specify a qualified name such as com.ibm.NewName 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 in the same project for elements that the transformation generates.
After you run the UML-to-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 Javadoc. The transformation owns Java elements that are marked with @generated tags. When you rerun the transformation, the transformation overwrites these elements 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.
If you do not want to keep the source UML model, you can use the visualization features of the transformation to delete the elements and replace them with visual references to the corresponding 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 reflected automatically in the Java file. Likewise, 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 the UML source model elements.