Is there a template or something for generating a switch statement for Java enum in Eclipse?
So that when I got an enum and I want to have a switch with all the values, I didn't have to write all it myself?
Is there a template or something for generating a switch statement for Java enum in Eclipse?
So that when I got an enum and I want to have a switch with all the values, I didn't have to write all it myself?
Not that I know about. I think that you'd have to write it yourself.
I would be very surprised if you find this kind of template, because all the values in switch statement can do something totally different. I cannot see the way in which such template would work.
I know this answer is not helping much... sorry :)
The content assists in Eclipse 3.4 will help you write the code. Just type case
and press Ctrl+Space and you'll get a list of unused enums.
There certainly is, at least in 3.5.
Starting with something like this:
switch(a.getType()){
}
All you need to do is click on the switch keyword and hit CTRL+1. You should get a drop down which includes the option "Add missing case statements"