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


##########
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:
   @mariofusco the `NameExpr()` fallback was taken over the to code before this 
PR, but passing a non-pareseable definition just pushes the error downstream to 
the runtime compiler. I will remove it and throw the parse argument at compile 
time which is appropriate in the exec model, I believe.



-- 
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