diff --git a/src/main/java/com/helger/jcodemodel/JCase.java b/src/main/java/com/helger/jcodemodel/JCase.java index c84d6532..7f940ff1 100644 --- a/src/main/java/com/helger/jcodemodel/JCase.java +++ b/src/main/java/com/helger/jcodemodel/JCase.java @@ -118,7 +118,17 @@ public void state (@Nonnull final JFormatter f) } else { - f.print ("case ").generable (m_aLabelExpr).print (':').newline (); + // Hack for #41 :) + IJExpression aLabelName; + if (m_aLabelExpr instanceof JEnumConstant) + { + // Just use the name, but not the type of the enum + aLabelName = f1 -> f1.print (((JEnumConstant) m_aLabelExpr).name ()); + } + else + aLabelName = m_aLabelExpr; + + f.print ("case ").generable (aLabelName).print (':').newline (); } if (m_aBody != null) f.statement (m_aBody); diff --git a/src/main/java/com/helger/jcodemodel/JEnumConstant.java b/src/main/java/com/helger/jcodemodel/JEnumConstant.java index 502b4be1..34658eb9 100644 --- a/src/main/java/com/helger/jcodemodel/JEnumConstant.java +++ b/src/main/java/com/helger/jcodemodel/JEnumConstant.java @@ -209,11 +209,7 @@ public void declare (@Nonnull final JFormatter f) public void generate (@Nonnull final JFormatter f) { - // Type must not be emitted - see issue #41 - if (false) - f.type (m_aType).print ('.').print (m_sName); - else - f.print (m_sName); + f.type (m_aType).print ('.').print (m_sName); } @Override