Updated code with communication and notification.

This commit is contained in:
piyuskag
2024-10-27 21:33:18 +05:30
59 changed files with 2479 additions and 153 deletions

View File

@@ -1,5 +1,6 @@
package net.gepafin.tendermanagement.util;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
@@ -310,6 +311,23 @@ public class Utils {
return new StringTokenizer(header, ",").nextToken().trim();
}
public static <T> List<T> convertJsonToList(String json, TypeReference<List<T>> typeRef) {
ObjectMapper objectMapper = new ObjectMapper();
try {
return objectMapper.readValue(json, typeRef);
} catch (IOException e) {
e.printStackTrace();
return Collections.emptyList();
}
}
public static String convertObjectToJson(Object obj) {
try {
if(obj == null){return null;}
return new ObjectMapper().writeValueAsString(obj);
} catch (JsonProcessingException e) {
log.error("Failed to convert object to JSON: {}", e.getMessage(), e);
throw new RuntimeException("Failed to convert object to JSON", e);}}
public static String replaceSpacesWithUnderscores(String content) {
if (content == null) {