Generating getter and setter methods through UML-to-Java transformations

You can specify that the transformation generate a field with getter and setter methods for each UML property.
Whether the transformation generates a setter method for a UML property depends on specific values of the property in the source model. You can check the values of the UML property in the Properties view:
  • On the General tab, if you select the property's Leaf or Read Only check box, no setter is generated. If you select the property's Derived check box, the setter implementation is empty.
  • On the Advanced tab, if you set the property's Is Leaf or Is Read Only value to true, no setter is generated. If you set the property's Is Derived value to true, the setter implementation is empty.
To generate getter and setter methods for Java™ classes that the transformation generates:
  1. In the Project Explorer view, right-click a transformation configuration file; then click Open.
  2. Complete one of the following steps:
    • If you are editing a UML-to-Java transformation configuration, click the UML to Java Options tab.
    • If you are editing a UML-to-Java (deprecated) transformation configuration, click the Properties tab.
  3. Select the Generate getters and setters check box.
  4. Click File > Save.
The next time that you run the transformation, for each attribute that is part of a source UML model element, the transformation generates getter and setter methods in the Java source code.
Note: If you create a new UML-to-Java transformation configuration, you can specify this information on the UML to Java Options page of the New Transformation Configuration wizard. If you create a new UML-to-Java (deprecated) transformation configuration, you can specify this information on the Properties page of the New Transformation Configuration wizard.

Feedback