Updated code

This commit is contained in:
rajesh
2025-03-24 16:29:30 +05:30
parent bbcbe0d894
commit 54b17b5c59
2 changed files with 64 additions and 36 deletions

View File

@@ -796,4 +796,22 @@ public class Utils {
return null;
}
}
/**
* Extracts a Map from a parent Map safely.
*/
public static Map<String, Object> extractMap(Map<String, Object> parentMap, String key) {
Object obj = parentMap.get(key);
if (obj instanceof Map<?, ?> map) {
return (Map<String, Object>) map;
}
return null;
}
/**
* Extracts a String from a Map safely.
*/
public static String extractString(Map<String, Object> parentMap, String key) {
Object obj = parentMap.get(key);
return (obj instanceof String str) ? str : null;
}
}