ChinchuAjith commented on code in PR #6770:
URL:
https://github.com/apache/incubator-kie-drools/pull/6770#discussion_r3489711097
##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/dialectHandlers/BFEELDialectHandler.java:
##########
@@ -232,79 +230,55 @@ public Map<CheckedPredicate, BiFunction<Object, Object,
Object>> getGteOperation
: null;
if (greater == null && equal == null) {
- return Boolean.FALSE; // BFEEL default
+ return Boolean.FALSE; // BFEEL default for
incompatible types
}
if (Boolean.TRUE.equals(greater) ||
Boolean.TRUE.equals(equal)) {
return Boolean.TRUE;
}
return Boolean.FALSE;
});
-
- // Fall back to common >= operations for all other cases
- map.putAll(getCommonGteOperations(ctx));
return map;
}
@Override
public Map<CheckedPredicate, BiFunction<Object, Object, Object>>
getGtOperations(EvaluationContext ctx) {
Map<CheckedPredicate, BiFunction<Object, Object, Object>> map = new
LinkedHashMap<>();
- // Any non-Boolean coerces to false, so (false,false) --> false
+ // BFEEL: null returns FALSE (not null like standard FEEL)
map.put(
- new CheckedPredicate((left, right) -> {
- Boolean leftBool = (left instanceof Boolean) ? (Boolean)
left : Boolean.FALSE;
- Object rightValue = evalRight(right, ctx);
- Boolean rightBool = (rightValue instanceof Boolean) ?
(Boolean) rightValue : Boolean.FALSE;
- return Boolean.FALSE.equals(leftBool) &&
Boolean.FALSE.equals(rightBool);
- }, false),
+ new CheckedPredicate((left, right) -> left == null || right ==
null, false),
(left, right) -> Boolean.FALSE);
- // non-Boolean coercion to false
- map.put(
- new CheckedPredicate((left, right) -> (!(left instanceof
Boolean) || !(right instanceof Boolean)), false),
- (left, right) -> {
- Boolean leftBool = (left instanceof Boolean) ? (Boolean)
left : Boolean.FALSE;
- Boolean rightBool = (right instanceof Boolean) ? (Boolean)
right : Boolean.FALSE;
- return leftBool || rightBool;
- });
-
- // numeric/comparable > logic
+ // BFEEL: All other comparisons (numeric, dates, strings, Booleans,
etc.)
map.put(
new CheckedPredicate((left, right) -> true, false),
(left, right) -> {
Boolean greater = compare(left, right,
(l, r) -> l.compareTo(r) > 0);
return Objects.requireNonNullElse(greater, Boolean.FALSE);
});
Review Comment:
Resolved
--
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]