I have the following method:
private void setClientAdditionalInfo(Map map, Client client, User user) {
Map additionalInfo = (Map) map.get("additionalInfo");
if (checkMapProperty(additionalInfo, "gender")) {
client.setGender(additionalInfo.get("gender").toString());
}
if (checkMapProperty(additionalInfo, "race")) {
client.setRace(additionalInfo.get("race").toString());
}
if (checkMapProperty(additionalInfo, "ethnicity")) {
client.setEthnicity(additionalInfo.get("ethnicity").toString());
}
.....
12 more if statements are used in the similar way. The only difference being a different setter method name and a different parameter. Now, as the same pattern is repeated again and again, is there a way to reduce the code complexity?