mariofusco commented on code in PR #6738:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6738#discussion_r3479702255


##########
drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/declaredtype/EnumGenerator.java:
##########
@@ -104,8 +107,19 @@ private void createGetter(Type type, String key) {
     private void addEnumerationValue(EnumLiteralDescr enumLiteral) {
         EnumConstantDeclaration element = new 
EnumConstantDeclaration(enumLiteral.getName());
         for (String constructorArgument : enumLiteral.getConstructorArgs()) {
-            element.addArgument(new NameExpr(constructorArgument));
+            element.addArgument(parseConstructorArgument(constructorArgument));
         }
         enumDeclaration.addEntry(element);
     }
+
+    /**
+     * Parses an enum-constant constructor argument as a Java expression.
+     */
+    private Expression parseConstructorArgument(String constructorArgument) {
+        try {
+            return StaticJavaParser.parseExpression(constructorArgument);
+        } catch (ParseProblemException e) {
+            return new NameExpr(constructorArgument);
+        }
+    }

Review Comment:
   I see why you're doing this, but I agree with this comment. I wonder if 
there could be a safe way to discriminate between the correct use case that you 
want to enable and all other actual parsing errors.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to