Accepted answer

i think currently the only way to apply parameter prefixes for setter methods only is to write a new template for setter methods, but this template wouldn't be used by the accessor generator. you can see a list of existing templates under window->preferences->java->editor->templates, see this question for some hints on creating a template.

you can modify the eclipse settings to specify prefixes (and suffixes) for all types of variables either at the workspace or project level, this will apply to all methods though, not just setters. you can use the "clean up" feature to ensure your parameters are final.

to appease your code convention, you could specify that all instance variables are prefixed instead, that way your parameters will not override the instance variables, you may not want to do that though.

variable prefixes

to modify the workspace settings, go to window->preferences->java->code style, and then edit the list to use your preferred prefixes/suffixes.

to modify the project settings, open the project properties (alt + enter), then select java code style, select enable project specific settings, then edit the preferences as for the workspace.

to enable a particular prefix only for setter methods, you'd have to delve into the internals of the code templates to identify and modify the setter

final parameters

to ensure all method parameters are final, you can modify the java clean up processor to add final to parameters. under window->preferences->java->code style->clean up, you can copy or edit the active profile. under the code style tab, select use modifier 'final' where possible in the variable declarations section, then ensure parameter is selected. clean up will be applied when you run source->clean up

to have final parameters applied automatically on each save, you can modify the save actions, under window->**preferences->java->editor->save actions, ensure perform the selected actions on save box is selected (this will also format your code and organise imports if you wish), select the additional actions option, and the configure, then under code style, apply the same as above


you can use fast code eclipse plugin to do this pretty easily.


eclipse --> preferences --> java --> code style --> code templates --> code


very simple...

  1. in your project, under the root project folder, create a folder called .settings (it might already be there).
  2. in this folder, create a text file called org.eclipse.jdt.core.prefs
  3. in this file, include the following line:


that's it, your done. it should just work. i couldn't find proper documentation for this, but here are some other options you might set:

org.eclipse.jdt.core.codecomplete.argumentprefixes= org.eclipse.jdt.core.codecomplete.argumentsuffixes= org.eclipse.jdt.core.codecomplete.fieldprefixes= org.eclipse.jdt.core.codecomplete.fieldsuffixes= org.eclipse.jdt.core.codecomplete.localprefixes= org.eclipse.jdt.core.codecomplete.localsuffixes= org.eclipse.jdt.core.codecomplete.staticfieldprefixes= org.eclipse.jdt.core.codecomplete.staticfieldsuffixes=

Related Query