Howto: tell a method is a getter/setter?
Obviously, it must take into account the code naming preferences (prefix
& postfix) for fields.
Question 1: is there a simple way?
-
As IDEA treats them differently (they are 'properties', in the class
structure display), I secretly hope there is an easy/1-call way to get
this info.
If not, then I need to know :
Question 2: how to obtain the code naming preferences
-
Alain
Please sign in to leave a comment.
Have you tried the class PropertyUtil? With methods like: findPropertyGetter, isSimplePropertyGetter, etc.
Kirk Woll wrote:
> Have you tried the class PropertyUtil?
Thanks Kirk, ..
I didn't know PropertyUtil.
Unfortunately,
- the method only checks the method name, and
- I don't know how to have it use/set the user code style preferences.
I ran
PropertyUtil.isSimplePropertySetter(i_method);
through the test suites I used to build my own isSetter(), and it
erroneously detected a setter in :
public void setAge(int val) { }
public void setAge(int val) { age += val ;}
public void setAge(int val) { return;}
Alain
ping, JetBrains :
> Question 2: how to obtain the code naming preferences
I'm stuck (on this one).
Alain