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


##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/CeilingFunction.java:
##########
@@ -39,17 +42,15 @@ public FEELFnResult<BigDecimal> invoke(@ParameterName( "n" 
) BigDecimal n) {
     }
 
     public FEELFnResult<BigDecimal> invoke(@ParameterName( "n" ) BigDecimal n, 
@ParameterName( "scale" ) BigDecimal scale) {
-        if ( n == null ) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "n", "cannot be null"));
-        }
-        if ( scale == null ) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "scale", "cannot be null"));
+        try {
+            int coercedN = coerceIntegerNumber(n).orElseThrow(() -> new 
NoSuchElementException("n"));

Review Comment:
   Hi @ChinchuAjith 
   it seems that `coercedN` is not used at all ... what's missing here ? 🤔 



##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/FloorFunction.java:
##########
@@ -38,18 +41,16 @@ public FEELFnResult<BigDecimal> invoke(@ParameterName( "n" 
) BigDecimal n) {
         return invoke(n, BigDecimal.ZERO);
     }
 
-    public FEELFnResult<BigDecimal> invoke(@ParameterName( "n" ) BigDecimal n, 
@ParameterName( "scale" ) BigDecimal scale) {
-        if ( n == null ) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "n", "cannot be null"));
-        }
-        if ( scale == null ) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "scale", "cannot be null"));
+    public FEELFnResult<BigDecimal> invoke(@ParameterName("n") BigDecimal n, 
@ParameterName("scale") BigDecimal scale) {
+        try {
+            int coercedN = coerceIntegerNumber(n).orElseThrow(() -> new 
NoSuchElementException("n"));

Review Comment:
   Hi @ChinchuAjith
   it seems that coercedN is not used at all ... what's missing here ? 🤔



##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DecimalFunction.java:
##########
@@ -34,18 +37,17 @@ private DecimalFunction() {
         super( "decimal" );
     }
 
-    public FEELFnResult<BigDecimal> invoke(@ParameterName( "n" ) BigDecimal n, 
@ParameterName( "scale" ) BigDecimal scale) {
-        if ( n == null ) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "n", "cannot be null"));
-        }
-        if ( scale == null ) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "scale", "cannot be null"));
+    public FEELFnResult<BigDecimal> invoke(@ParameterName("n") BigDecimal n, 
@ParameterName("scale") BigDecimal scale) {
+        try {
+            int coercedN = coerceIntegerNumber(n).orElseThrow(() -> new 
NoSuchElementException("n"));

Review Comment:
   Hi @ChinchuAjith
   it seems that coercedN is not used at all ... what's missing here ? 🤔



##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RoundUpFunction.java:
##########
@@ -38,17 +41,16 @@ public FEELFnResult<BigDecimal> invoke(@ParameterName( "n" 
) BigDecimal n) {
         return invoke(n, BigDecimal.ZERO);
     }
 
-    public FEELFnResult<BigDecimal> invoke(@ParameterName( "n" ) BigDecimal n, 
@ParameterName( "scale" ) BigDecimal scale) {
-        if ( n == null ) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "n", "cannot be null"));
-        }
-        if ( scale == null ) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "scale", "cannot be null"));
-        }
-        // Based on Table 76: Semantics of numeric functions, the scale is in 
range −6111 .. 6176
-        if (scale.compareTo(BigDecimal.valueOf(-6111)) < 0 || 
scale.compareTo(BigDecimal.valueOf(6176)) > 0) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "scale", "must be in range between -6111 
to 6176."));
+    public FEELFnResult<BigDecimal> invoke(@ParameterName("n") BigDecimal n, 
@ParameterName("scale") BigDecimal scale) {
+        try {
+            int coercedN = coerceIntegerNumber(n).orElseThrow(() -> new 
NoSuchElementException("n"));

Review Comment:
   Hi @ChinchuAjith
   it seems that coercedN is not used at all ... what's missing here ? 🤔



##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RoundHalfDownFunction.java:
##########
@@ -38,17 +41,16 @@ public FEELFnResult<BigDecimal> invoke(@ParameterName( "n" 
) BigDecimal n) {
         return invoke(n, BigDecimal.ZERO);
     }
 
-    public FEELFnResult<BigDecimal> invoke(@ParameterName( "n" ) BigDecimal n, 
@ParameterName( "scale" ) BigDecimal scale) {
-        if ( n == null ) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "n", "cannot be null"));
-        }
-        if ( scale == null ) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "scale", "cannot be null"));
-        }
-        // Based on Table 76: Semantics of numeric functions, the scale is in 
range −6111 .. 6176
-        if (scale.compareTo(BigDecimal.valueOf(-6111)) < 0 || 
scale.compareTo(BigDecimal.valueOf(6176)) > 0) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "scale", "must be in range between -6111 
to 6176."));
+    public FEELFnResult<BigDecimal> invoke(@ParameterName("n") BigDecimal n, 
@ParameterName("scale") BigDecimal scale) {
+        try {
+            int coercedN = coerceIntegerNumber(n).orElseThrow(() -> new 
NoSuchElementException("n"));

Review Comment:
   Hi @ChinchuAjith
   it seems that coercedN is not used at all ... what's missing here ? 🤔



##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RoundDownFunction.java:
##########
@@ -38,17 +41,16 @@ public FEELFnResult<BigDecimal> invoke(@ParameterName( "n" 
) BigDecimal n) {
         return invoke(n, BigDecimal.ZERO);
     }
 
-    public FEELFnResult<BigDecimal> invoke(@ParameterName( "n" ) BigDecimal n, 
@ParameterName( "scale" ) BigDecimal scale) {
-        if ( n == null ) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "n", "cannot be null"));
-        }
-        if ( scale == null ) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "scale", "cannot be null"));
-        }
-        // Based on Table 76: Semantics of numeric functions, the scale is in 
range −6111 .. 6176
-        if (scale.compareTo(BigDecimal.valueOf(-6111)) < 0 || 
scale.compareTo(BigDecimal.valueOf(6176)) > 0) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "scale", "must be in range between -6111 
to 6176."));
+    public FEELFnResult<BigDecimal> invoke(@ParameterName("n") BigDecimal n, 
@ParameterName("scale") BigDecimal scale) {
+        try {
+            int coercedN = coerceIntegerNumber(n).orElseThrow(() -> new 
NoSuchElementException("n"));

Review Comment:
   Hi @ChinchuAjith
   it seems that coercedN is not used at all ... what's missing here ? 🤔



##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RoundHalfUpFunction.java:
##########
@@ -38,17 +41,16 @@ public FEELFnResult<BigDecimal> invoke(@ParameterName( "n" 
) BigDecimal n) {
         return invoke(n, BigDecimal.ZERO);
     }
 
-    public FEELFnResult<BigDecimal> invoke(@ParameterName( "n" ) BigDecimal n, 
@ParameterName( "scale" ) BigDecimal scale) {
-        if ( n == null ) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "n", "cannot be null"));
-        }
-        if ( scale == null ) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "scale", "cannot be null"));
-        }
-        // Based on Table 76: Semantics of numeric functions, the scale is in 
range −6111 .. 6176
-        if (scale.compareTo(BigDecimal.valueOf(-6111)) < 0 || 
scale.compareTo(BigDecimal.valueOf(6176)) > 0) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "scale", "must be in range between -6111 
to 6176."));
+    public FEELFnResult<BigDecimal> invoke(@ParameterName("n") BigDecimal n, 
@ParameterName("scale") BigDecimal scale) {
+        try {
+            int coercedN = coerceIntegerNumber(n).orElseThrow(() -> new 
NoSuchElementException("n"));

Review Comment:
   Hi @ChinchuAjith
   it seems that coercedN is not used at all ... what's missing here ? 🤔



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