ChinchuAjith commented on code in PR #6519:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6519#discussion_r2541445461


##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/dialectHandlers/BFEELDialectHandler.java:
##########
@@ -0,0 +1,326 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.dmn.feel.lang.ast.dialectHandlers;
+
+import org.kie.dmn.feel.lang.EvaluationContext;
+import org.kie.dmn.feel.lang.FEELDialect;
+import org.kie.dmn.feel.lang.types.impl.ComparablePeriod;
+import org.kie.dmn.feel.util.BooleanEvalHelper;
+
+import java.math.BigDecimal;
+import java.time.Duration;
+import java.time.LocalDate;
+import java.time.chrono.ChronoPeriod;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.function.BiFunction;
+
+import static org.kie.dmn.feel.lang.ast.infixexecutors.InfixExecutorUtils.*;
+import static org.kie.dmn.feel.util.BooleanEvalHelper.evalRight;
+
+/**
+ *  Handler implementation of the DialectHandler interface providing BFEEL 
specific
+ *  functionalities
+ */
+public class BFEELDialectHandler extends DefaultDialectHandler implements 
DialectHandler {
+
+    /**
+     * Builds the BFeel specific 'Addition' operations.
+     * @param ctx : Current Evaluation context
+     * @return : a Map of CheckedPredicate to BiFunction representing the 
BFeel specific 'Addition' operations
+     */
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getAddOperations(EvaluationContext ctx) {
+        Map<CheckedPredicate, BiFunction<Object, Object, Object>> map = new 
LinkedHashMap<>();
+
+        // any String operand → concatenate both as strings
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof String 
|| right instanceof String, false),
+                (left, right) -> {
+                    String leftNum = getString(left);
+                    String rightNum = getString(right);
+                    return leftNum + rightNum;
+                }
+        );
+
+        // date + number → return the number
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof 
LocalDate && right instanceof Number, false),
+                (left, right) -> right
+        );
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof Number 
&& right instanceof LocalDate, false),
+                (left, right) -> left
+        );
+
+        // Number + null → number
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof Number 
&& right == null, false),
+                (left, right) -> left
+        );
+
+        // null + Number → number
+        map.put(
+                new CheckedPredicate((left, right) -> left == null && right 
instanceof Number, false),
+                (left, right) -> right
+        );
+
+        map.putAll(getCommonAddOperations(ctx));
+        return map;
+    }
+
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getAndOperations(EvaluationContext ctx) {
+        Map<CheckedPredicate, BiFunction<Object, Object, Object>> map = new 
LinkedHashMap<>();
+        FEELDialect dialect = ctx.getFEELDialect();
+        // Special case: true AND otherwise → false
+        map.put(
+                new CheckedPredicate((left, right) -> {
+                    Boolean leftBool = 
BooleanEvalHelper.getBooleanOrDialectDefault(left, dialect);
+                    Object rightValue = evalRight(right, ctx);
+                    Boolean rightBool = 
BooleanEvalHelper.getBooleanOrDialectDefault(rightValue, dialect);
+                    return Boolean.TRUE.equals(leftBool) && 
Boolean.FALSE.equals(rightBool);
+                }, false),
+                (left, right) -> Boolean.FALSE
+        );
+
+        // Special case: otherwise AND true → false
+        map.put(
+                new CheckedPredicate((left, right) -> {
+                    Boolean leftBool = 
BooleanEvalHelper.getBooleanOrDialectDefault(left, dialect);
+                    Object rightValue = evalRight(right, ctx);
+                    Boolean rightBool = 
BooleanEvalHelper.getBooleanOrDialectDefault(rightValue, dialect);
+                    return leftBool == null && Boolean.TRUE.equals(rightBool);
+                }, false),
+                (left, right) -> Boolean.FALSE
+        );
+
+        // Special case: otherwise AND otherwise → false
+        map.put(
+                new CheckedPredicate((left, right) -> {
+                    Boolean leftBool = 
BooleanEvalHelper.getBooleanOrDialectDefault(left, dialect);
+                    Object rightValue = evalRight(right, ctx);
+                    Boolean rightBool = 
BooleanEvalHelper.getBooleanOrDialectDefault(rightValue, dialect);
+                    return leftBool == null && Boolean.FALSE.equals(rightBool);
+                }, false),
+                (left, right) -> Boolean.FALSE
+        );
+        map.putAll(getCommonAddOperations(ctx));

Review Comment:
   This has been corrected. It was added accidently



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