drccrd commented on code in PR #6738:
URL:
https://github.com/apache/incubator-kie-drools/pull/6738#discussion_r3481206181
##########
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:
Thank you @tkobayas and @mariofusco - I will check this point.
--
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]