Daily Archives: November 7, 2004

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