From 6c89dca99406117490aba70165687f794e06ec72 Mon Sep 17 00:00:00 2001 From: nithin-sudarsan Date: Fri, 11 Aug 2023 14:34:09 +0530 Subject: [PATCH] Updated #sub functionality --- pom.xml | 2 +- src/main/java/org/perfios/Logic.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 394fd54..280b6ac 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.perfios data-mapper - 1.2.2 + 1.2.3 11 diff --git a/src/main/java/org/perfios/Logic.java b/src/main/java/org/perfios/Logic.java index bd1419e..d566ef3 100644 --- a/src/main/java/org/perfios/Logic.java +++ b/src/main/java/org/perfios/Logic.java @@ -112,7 +112,7 @@ static Map transformJson(Map,List> transfor else if (rhs.contains("#mul")){ value = findProduct(json, rhs); } - else if(rhs.contains("div")){ + else if(rhs.contains("#div")){ value = findQuotient(json, rhs); } else if (rhs.contains("#default")){ @@ -215,7 +215,13 @@ else if (value instanceof ArrayList) { if (areAllNumbers(listValue)) { // Nested list contains only numbers, calculate the nested sum double nestedSum = diffNestedNumbers(listValue,diff); - diff -= nestedSum; + if(initial){ + diff+=nestedSum; + initial=false; + } + else { + diff=nestedSum; + } } else { throw new RuntimeException("All elements in the ArrayList must be numbers"); }