Customize getter/setters

Hi,

is there a way to customize how getters/setters are created, more specifically named?
Our naming convention is not to use get/set (please don't start a discussion about that), so whenever using alt-insert generate getters/setters I need to manually remove all the "get/set" prefixes and change the caps of the first letter thereafter.

Thanks,
Max Hajek
Vienna, Austria

5 comments
Comment actions Permalink

Is saying "right on!" to your naming convention considered starting a discussion?

There are other aspects of attribute naming than the Generate Getters and Setters actions. What you want was one of the first things I asked for when I started (circa IDEA version 6.0). I was told that this would not be supported.


Randall Schulz

0
Comment actions Permalink

Oh, you are saying the reaction was this is not even planned on being supported?

As for the naming convention discussion : basically we are in a position where we do not use anything relying on the beans convention (writing a game server).
My personal opinion is that the whole get/set business evolved out of Java not having syntactic sugar like properties. So the beans convention was introduced to give certain libraries a somewhat reliable way of distinguishing property-style methods from others. That means the naming convention was fixing a shortcoming of the language. It is somewhat surprising that in the meantime that shortcoming itself has not been fixed (Borland Pascal had properties a *long while* ago, as had their version of C++, nowadays C# has them, and plenty of other languages, too). Of course people tend to object that properties are evil because they hide the fact that something more than just setting/getting a field value could go on behind the scenes. OTOH, what's the difference with get/set name prefixes? And why should the user of my class have to care what I'm doing behind the scenes? But that's a discussion smarter minds than me have been arguing from both sides of the aisle.
Now anyway, when you can safely count on not needing any of those libraries (admittedly a rather rare occasion for the typical Java project), I see no reason why you should use that work-around. It's 3 (or 4, however you count) characters which repeat themselves over and over and really do not convey any relevant information. If not for IDEAs superb camelHunk editor feature, it would mean one has to type those 3 chars whenever invoking auto-completion before the editor can start to rule out irrelevant alternatives.

Back to the original subject, I would have expected that one can customize those. Not necessarily via a nice GUI, but simply find some text file somewhere to edit. It seems one cannot. That's a real shame

0
Comment actions Permalink

You expect the customization of a quasi-standard? Do Eclipse or NetBeans
support that? Otherwise I can't understand your expectation.

0
Comment actions Permalink

Hi,

If you really wanted to do this, and I think it would be a good thing, then you'd also want to generate a BeanInfo class whenever the attribute accessors did not conform to the getGagMe() / setGagMe(float howSeverely) convention. More importantly (arguably) the Structure window should then also detect the presence of BeanInfo classes (whether generated by IDEA or not) and use them to detect and display properties.


Randall Schulz

0

Please sign in to leave a comment.