I have the below class with around 200 variables.
public class BaseDataDTO {
private CSVRecord rawData;
private List<InquiriesDataDTO> inquiriesData;
private ListTradesDataDTO> tradesData;
private List<CollectionsDataDTO> collectionsData;
private Long applicantId;
//cvv attributes
public String adg001;
private String adg002;
private String adg003;
private String adg004;
private String apg05;
-
-
private String apg199;
}
From a different class, I would like to access the instance variables through the variable names, is it possible to do? I need to do this since I need compare some another response with the instance variable of that class through a Map key. How can I achieve some thing to the effect of the text in bold below?
I do not want to use getter methods here since it is in a for loop for 200 times.
BaseDataDTO baseData = CSVParser.parseBaseData(fileName);
Map<String, String> attributes = fileLoader.withName("attributes.json").jsonToObject(Map.class);
for (String key : attributes.keySet()) {
String responseValue = response.getModelScores().get(0).getScoringInput().get("function_input").get(key).asText();
String expValue = baseData.get(key));
AssertEquals(responseValue, expValue);
}