Copilot commented on code in PR #4101:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4101#discussion_r2450735896


##########
jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/rule/DecisionRuleTypeEngineImpl.java:
##########
@@ -68,4 +70,33 @@ public void evaluate(RuleSetNodeInstance rsni, String 
inputNamespace, String inp
 
         rsni.triggerCompleted();
     }
+
+    Map<String, Object> getDMNAnnotatedAdjustedMap(RuleSetNodeInstance rsni) {
+        // Get inputs
+        Map<String, Object> inputs = getInputs(rsni);
+        // resolve inputs with the JsonResolver' objectMapper
+        Map<String, Object> jsonResolvedInputs = 
jsonResolver.resolveAll(inputs);
+        return getDMNAnnotatedAdjustedMap(inputs, jsonResolvedInputs);
+    }
+
+    Map<String, Object> getDMNAnnotatedAdjustedMap(Map<String, Object> 
rsniInputs, Map<String, Object> jsonResolvedInputs) {
+        Map<String, Object> toReturn = new HashMap<>(jsonResolvedInputs);
+        // Retrieving DMN-annotated inputs
+        Map<String, Object> dmnAnnotatedBeans = rsniInputs.entrySet()
+                .stream()
+                .filter(entry -> isDMNAnnotatedBean(entry.getValue()))
+                .collect(Collectors.toMap(Map.Entry::getKey, 
Map.Entry::getValue));
+        // replacing/adding DMN-annotated beans inside returned Map
+        toReturn.putAll(dmnAnnotatedBeans);
+        return toReturn;
+    }
+
+    boolean isDMNAnnotatedBean(Object bean) {
+        return bean != null && isDMNAnnotatedClass(bean.getClass());
+    }
+
+    boolean isDMNAnnotatedClass(Class<?> clazz) {
+        return !JavaBackedType.of(clazz).equals(BuiltInType.UNKNOWN);

Review Comment:
   [nitpick] The logic uses negation which makes it less intuitive. Consider 
using a positive check with a meaningful method name, such as `return 
JavaBackedType.of(clazz) instanceof JavaBackedType` or checking if it's a known 
type directly, to improve code clarity.
   ```suggestion
           return JavaBackedType.of(clazz) instanceof JavaBackedType;
   ```



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