Skip to content

Commit

Permalink
Hack for #41 that should suffice all requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed May 17, 2017
1 parent 995a619 commit cd65670
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 11 additions & 1 deletion src/main/java/com/helger/jcodemodel/JCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/com/helger/jcodemodel/JEnumConstant.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cd65670

Please sign in to comment.