Generating Indexed Property Getters/Setters in Eclipse
Question
By default, eclipse generates getters/setters according to JavaBeans regular properties style:
* public void setName(String name)
* public String getName()
As of J2SE 5.0 JavaBeans specification allows IndexedPropertyChangeEvents which have a different getter/setter naming scheme for arrays:
* public void setName(int index, String name)
* public String getName(int index)
* public void setName(String[] names)
* public String[] getName()
How can you configure eclipse to generate getters and setters which follow this style?
Solution 2
You cant. eclipse does not support that. – 01 Sep 26 '09 at 21:07
I think 01 is right - nobody's made it easy to accomplish this yet.
OTHER TIPS
If there was a simple option for it, it would be in the Windows->Preferences->Java->Code Style. This is where the setting for telling the generator to use "is" for the getter on boolean variables. You'd probably have to write a plug-in or alter the code generation mechanism.
As an alternative you can do them when you need them, with a template. Something along the lines of:
public void set${l:List} (int i, String s)
{
${l}.set(i, s);
}
public String get${l:List} (int i)
{
return ${l}.get(i);
}
And if not, there is always search and replace http://dev.eclipse.org/newslists/news.eclipse.tools.jdt/msg13332.html