Done ticket GEPAFINBE-39

This commit is contained in:
rajesh
2024-10-11 10:19:23 +05:30
parent 90aae05fa4
commit 8a14059b0c
18 changed files with 531 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
@@ -276,4 +277,30 @@ public class Utils {
}
}
public static Map<String, Map<String, String>> parseJsonContent(String jsonContent) {
ObjectMapper objectMapper = new ObjectMapper();
try {
return mapper.readValue(jsonContent, HashMap.class);
} catch (Exception exception) {
log.error(exception.getMessage());
}
return new HashMap<>();
}
// Utility method to replace placeholders with their values, handling nulls
public static String replacePlaceholders(String text, Map<String, String> placeholders) {
if (text == null) {
return "";
}
for (Map.Entry<String, String> entry : placeholders.entrySet()) {
text = replaceNull(text, entry.getKey(), entry.getValue());
}
return text;
}
// Method to safely replace nulls with an empty string or a default value
private static String replaceNull(String text, String target, String replacement) {
return text.replace(target, replacement != null ? replacement : "");
}
}