JaanusSiim
JaanusSiim

Reputation: 2192

Eclipse - generated method parameters final

Can Eclipse make parameters for generated methods (overwriting, implementing interface, etc.) final, and if so, how?

If I'm not mistaken, IntelliJ had an option for it. I could not find something similar in Eclipse.

I have become accustomed to making parameters final manually, but I am hoping for an automatic solution.

Upvotes: 19

Views: 6752

Answers (3)

Guido
Guido

Reputation: 47665

AFAIK, that is not possible. I've not found any option to customize it under Window > Preferences > Java > Editor > Templates or under Window > Preferences > Java > Code Style > Code Templates.

Anyway, Eclipse 3.3+ comes with "save actions", an alternative mechanism for doing that. Under Preferencens > Java > Editors > Save actions it is possible to configure "additional save actions". On the code style tab there is an option to automatically add final modifiers to private fields, method parameters and local variables.

Upvotes: 12

Bruno De Fraine
Bruno De Fraine

Reputation: 47296

It is indeed in the "save actions". Check this blog post for a screenshot: Eclipse and the automagical final

Upvotes: 6

JaanusSiim
JaanusSiim

Reputation: 2192

There's cleanup options under 'Project' -> 'Preferences' -> 'Java Code Style' -> 'Clean up', but these can be applied after code has been generated...

Upvotes: 1

Related Questions