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?
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"
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.