Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate all setXXX calls of a POJO in Eclipse?

Tags:

eclipse

jpa

Im currently doing a lot of testing with JPA entities, where i have to keep calling the setter methods on the entity that looks something like this :

myEntity.setXXX(value); myEntity.setYYY(value); myEntity.setZZZ(value); 

Is there any magic shortcut or menu in eclipse IDE to generate all the setter-method-calls that starts with "set", like those displayed in the ctrl-space (auto completion) popup (i think the inherited methods from Object are not being shown at popup) ?

So im imagining something like :

  1. i type myEntity.set
  2. and myEntity.set* are generated right away

Im a lazy programmer and currently using Eclipse Helios IDE.

Thank you !


Edit

Im not looking for source -> generate getter and setter, because that would helps me in generating the methods itself. Generating the method calls is what i want to achieve.

like image 987
Albert Gan Avatar asked Mar 12 '11 04:03

Albert Gan


People also ask

Can generate getters and setters in Eclipse?

To generate getters and setters, do the following: Create the fields you want in the class then press Alt+Shift+S, R. A dialog will pop up allowing you to choose the fields you want to generate getters and setters for. Click Select All to create getters/setters for all fields.


1 Answers

I have found the answer (I was always searching for this thing)...

The easiest way is to expand the class members in the "Package Explorer", sort them by name, multi-select all the setters, and then you have in the clipboard all the method names...

;-)

like image 168
Oscar Avatar answered Sep 24 '22 16:09

Oscar