Create Getters and Setters

This dialog lets select the getter and setter methods to create.

Use Generate Getters and Setters from the Source menu or the context menu on a selected field or type, or a text selection in a type to open the dialog. The Generate Getters and Setters dialog shows getters and setters for all fields of the selected type. The methods are grouped by the type's fields.

The names of the getter and setter methods are derived from the field name. If you use a prefix or suffix for fields (e.g. fValue, _value, val_m), you can specify the suffixes and prefixes in the Code Style preference page (Windows > Preferences > Java > Code Style).

When pressing OK, all selected getters and setters are created.

Option

Description

Select getters and setters to create

A tree containing getter and setter methods that can be created. Getters and setters are grouped by field their associated field. 

Select All

Select all getter and setter methods

Deselect All

Deselect all getter and setter methods

Select Getters

Select all getter methods

Insertion point

Defines where in the type body the new methods are inserted

Sort by

Defines how to sort the new methods:
  • in getter/setter pairs
  • first getters, then setters

Access modifiers

Defines the access modifiers of the new methods

Generate method comments

Controls whether Javadoc comments are added to the created methods. The comment templates are defined on the Code Templates preference page.

Related reference

Source actions