1

Is there a possibility to let Eclipse generate getter/setter in this form:

public int a;
public int b;

public get0(){return a;}
public get1(){return b;}
public set0(int val){a = val;}

etc. ?

Michael Brenndoerfer
  • 3,483
  • 2
  • 39
  • 50

2 Answers2

0

In Eclipse, there is an option to automatically generate Getters and Setters for all instance-fields you have in your class (or you can select the ones that you want, whatever). You'll want to go to the Source tab, and scroll down to Generate Getters and Setters.... From there, you should be able to choose which ones you want to generate.
As for actually calling them something other than the name of the variable, Eclipse doesn't really provide you with much. It may be better to do it manually, or even to make your own code generator, if you really want to.


Edit

You can go and fiddle with the Code Template, as shown at the bottom of the Generate Getters and Setters popup.

Zesty Memes
  • 442
  • 2
  • 11
0

Right click where you want your getters -> source -> Generate Getters and Setters. Now only select the the getters option. It will populate all your getters. Then repeat this for the setters below your getters. Then you will have the format you want.

Chris Bolton
  • 2,162
  • 4
  • 36
  • 75