Done ticket GEPAFINBE-39
This commit is contained in:
@@ -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 : "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user