Creating Getter and Setter Methods

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  UML Diagrams > Structural Diagrams > Class Diagram >

Creating Getter and Setter Methods

During the modeling process it is often necessary to create get/set methods for existing attributes. UModel supplies you with two separate methods to achieve this:

 

Drag and drop an attribute into the operation compartment
Use the context menu to open a dialog box allowing you to manage get/set methods

 

 

To create getter/setter methods using drag and drop:

Drag an attribute from the Attribute compartment and drop it in the Operations compartment.

get-set1

A pop-up menu appears at this point allowing you to decide what type of get/set method you want to create.

get-set2

Selecting the first item creates a get and set method for interestRate:float.

get-set3

 

 

To create getter/setter methods using the context menu:

1.Right-click the class title, e.g. SavingsAccount, and select the context menu option Create Getter/Setter Operations. The Create Getters/Setters dialog box opens displaying all attributes available in the currently active class.

get-set4

2.Use the buttons to select the items as a group, or click the getter/setter check boxes individually.

 

Note:You can also right-click a single attribute and use the same method to create an operation for it.

© 2019 Altova GmbH