Eclipse trick: Custom getter-setter

I don’t want to challenge R.J. but I feel this trick is quite interesting.
During the last weeks I have found quite annoying to use the conventions of the projects I am contributing to, because they impose the usage of m_ and s_ notations and for a long time I have considered that this is a killer for the getter/setter generation in Eclipse.
But no, it is not: you can configure Eclipse to consider some prefixes and suffixes and these will be removed from the generated getters and setters.
Step by step:
– Window -> Preferences -> Java -> Code Style
– Variable type: Fields and add the m_ prefix
– Variable type: Static fields and add the s_ prefix (if you really use getters/setters for static fields [blink/].
Congrats again to the guys developing Eclipse!


1 Comment

Filed under Uncategorized

One response to “Eclipse trick: Custom getter-setter

  1. Shivkumar

    Thank you! That was really helpful!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s