Resolved conflicts

This commit is contained in:
nisha
2024-09-20 19:40:26 +05:30
7 changed files with 83 additions and 45 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
}
}
}
}