Fixed vaidation errors for createupdate application API.

This commit is contained in:
piyushkag
2025-01-23 13:16:11 +05:30
parent 1101fe277e
commit 45aaf4f667
2 changed files with 24 additions and 1 deletions

View File

@@ -407,6 +407,29 @@ public class Utils {
return input.toString();
}
public static String convertToStringForFormFieldValue(Object input) {
if (input == null) {
return null; // Return string "null" for null input
}
if (input instanceof String) {
return (String) input; // Return the string directly if input is a string
}
if (input instanceof Collection<?>) {
// Handle collections (List, Set, etc.)
return convertCollectionToString((Collection<?>) input);
}
if (input instanceof Map<?, ?>) {
// Handle maps
return convertMapToString((Map<?, ?>) input);
}
// For other types (like Integer, Boolean, etc.), use toString()
return input.toString();
}
private static String convertCollectionToString(Collection<?> collection) {
try {
return mapper.writeValueAsString(collection); // Convert the collection to a JSON string