Done ticket GEPAFINBE-162
This commit is contained in:
@@ -11,6 +11,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -27,6 +28,8 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.model.request.GlobalFilters;
|
||||
import net.objecthunter.exp4j.Expression;
|
||||
import net.objecthunter.exp4j.ExpressionBuilder;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -54,6 +57,9 @@ import javax.crypto.Cipher;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||
|
||||
@@ -753,6 +759,23 @@ public class Utils {
|
||||
private static Map<String, Object> defaultErrorResponse() {
|
||||
return Collections.singletonMap("message", Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
}
|
||||
public static List<String> extractValues(String input) {
|
||||
List<String> extractedValues = new ArrayList<>();
|
||||
Pattern pattern = Pattern.compile("\\{(.*?)\\}"); // Regex to match {value}
|
||||
Matcher matcher = pattern.matcher(input);
|
||||
|
||||
|
||||
while (matcher.find()) {
|
||||
extractedValues.add(matcher.group(1)); // Extract value inside {}
|
||||
}
|
||||
return extractedValues;
|
||||
}
|
||||
public static double evaluateExpression(String expression) {
|
||||
try {
|
||||
Expression exp = new ExpressionBuilder(expression).build();
|
||||
return exp.evaluate();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Double.NaN; // Return NaN if the expression is invalid
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user