I don't know if it's possible to do this as a template, because the template would have to know which enum type you were using. But you could write a little script to print out the statement for you, and then just copy its output into your source file.
public class SwitchWriter {
public static void printSwitchStatement(String varName, Class<?> E) {
System.out.format("switch(%s) {\n", varName);
for (Object o : E.getEnumConstants()) {
System.out.format("case %s:\n // TODO: Auto-generated switch statement stub\n break;\n", o);
}
System.out.println("default:\n // TODO: Auto-generated switch statement stub\n}");
}
}
Output of SwitchWriter.printSwitchStatement("action", java.awt.Desktop.Action.class)
:
switch(action) {
case OPEN:
// TODO: Auto-generated switch statement stub
break;
case EDIT:
// TODO: Auto-generated switch statement stub
break;
case PRINT:
// TODO: Auto-generated switch statement stub
break;
case MAIL:
// TODO: Auto-generated switch statement stub
break;
case BROWSE:
// TODO: Auto-generated switch statement stub
break;
default:
// TODO: Auto-generated switch statement stub
}