jaxb-codemodel
jaxb-codemodel copied to clipboard
error: an enum switch case label must be the unqualified name of an enumeration constant
the code generator uses qualified enum constant refs in switch-case constructs. I'll add a test case.
error: an enum switch case label must be the unqualified name of an enumeration constant case MyEnumWithValuesButWithoutConstructor._50 :
Affected Versions
[2.6]
Reported by unrh265h
unrh265h said:
@Test
public void testEnumSwitch() throws Exception {
JCodeModel cm = new JCodeModel();
JDefinedClass cls = cm.rootPackage()._class(JMod.PUBLIC, "EnumSwitch", ClassType.ENUM);
JMethod toStringMethod = cls.method(JMod.PUBLIC, String.class, "toString");
toStringMethod.annotate(Override.class);
JSwitch sw = toStringMethod.body()._switch(JExpr._this());
String enumConstName = "AA";
JEnumConstant enumConst = cls.enumConstant(enumConstName);
JCase cse = sw._case(enumConst);
ByteArrayOutputStream baos = new AccessibleByteArrayOutputStream();
cm.build(new SingleStreamCodeWriter(baos));
assertTrue(baos.toString().contains("case AA:"));
}
phax said: This was fixed by https://github.com/phax/jcodemodel/issues/41
This issue was imported from java.net JIRA CODEMODEL-25