Updated put api of call

This commit is contained in:
nisha
2024-09-20 19:37:47 +05:30
parent 79603a0c0d
commit c1939102c7
5 changed files with 28 additions and 4 deletions

View File

@@ -12,6 +12,7 @@ import org.apache.commons.collections4.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
@@ -147,4 +148,17 @@ public class Utils {
}
return null;
}
public static <T> void retainOnlySpecificFields(T requestObject, List<T> retainFields) throws IllegalAccessException {
// Get all declared fields of the request object's class
Field[] fields = requestObject.getClass().getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true); // To allow access to private fields
// Check if the field is in the retainFields list
if (!retainFields.contains(field.getName())) {
field.set(requestObject, null); // Set the field to null if not in the retain list
}
}
}
}