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


##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/NumberEvalHelper.java:
##########
@@ -66,12 +67,47 @@ public static BigDecimal getBigDecimalOrNull(Object value) {
         return null;
     }
 
+    /**
+     * The method handles various numeric types and converts the given object 
to an Integer
+     * Returns null If the conversion is not possible.
+     *
+     * @param value : The object to be converted.
+     * @return : An Integer representation of the value, or null if conversion 
is not possible.
+     */
+    public static Integer getIntegerOrNull(Object value) {
+        if ( value instanceof BigDecimal ) {
+            return ((BigDecimal) value).intValue();
+        }
+        if ( value instanceof BigInteger ) {
+            return ((BigInteger) value).intValue();
+        }
+        if ( value instanceof Number ) {
+            return ((Number) value).intValue();
+        }
+        return null;
+    }
+
     public static Object coerceNumber(Object value) {
         if ( value instanceof Number && !(value instanceof BigDecimal) ) {
             return getBigDecimalOrNull( value );
-        } else {
+        }  else {
             return value;
         }
     }
 
+    /**
+     * Converts the given object to an integer if it is an instance of Number.
+     * else it is returned unchanged.
+     *
+     * @param value : the object to be converted
+     * @return : an integer representation of the number if applicable, 
otherwise the original value
+     */
+    public static Optional<Integer> coerceIntegerNumber(Object value) {

Review Comment:
   Modified the method and javadoc



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