Updated put api of call
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user