I am looping over a collection of benefit codes. Each code is asssigned a type such as medical or dental. If the employee purchased that benefit, then I include it in the list. If they purchased no dental benefits, we want to add an item to the list for dental that indicates not purchased.
My AppConstants looks like so...
public static final String[][] benefitCodes = {
{"EE DENT INS", "Dental", "Employee"},
{"E1 DENT INS", "Dental", "Employee + 1"},
{"EFA DENT INS", "Dental", "Family"},
{"EE HLTH INS", "Medical", "Employee"},
{"EE HLTH INS- HRA", "Medical", "Employee"},
{"EE HLTH INS-STANDARD", "Medical", "Employee"},
{"EFA HLTH INS", "Medical", "Family"},
{"EFA HLTH INS-STANDAR", "Medical", "Family"},
{"E1 HLTH INS", "Medical", "Employee + 1"},
{"E1 HLTH INS-STANDARD", "Medical", "Employee + 1"},
};
Method looks like this...
private List<BenefitEnrollment> getAllEnrollments(Map<String, BenefitEnrollment> currentEnrollmentForDriver) {
List<BenefitEnrollment> allEnrollments = new ArrayList<BenefitEnrollment>();
// adds benefit that everyone has by default
allEnrollments.add(new BenefitEnrollment("Basic Life", "Basic Life", "Employee", true));
// loop through two dimensional array that holds the benefit codes with description
for(int i=0; i < AppConstants.knightBenefitCodes.length; i++) {
String benefitDescription = AppConstants.benefitCodes[i][0];
String benefitDisplayTitle = AppConstants.benefitCodes[i][1];
String benefitCoverage = AppConstants.benefitCodes[i][2];
// create the object
BenefitEnrollment benefit = new BenefitEnrollment();
benefit.setDescription(benefitDescription);
benefit.setDisplayTitle(benefitDisplayTitle);
// check if the current driver is enrolled in benefit
boolean hasBenefit = currentEnrollmentForDriver.containsKey(benefitDescription);
if(hasBenefit) {
benefit.setCoverage(benefitCoverage);
benefit.setAmount(currentEnrollmentForDriver.get(benefitDescription).getAmount());
benefit.setEnrolled(true);
allEnrollments.add(benefit);
}
// else if (...) { // need condition that adds item when nothing in say Dental purchased
// benefit.setCoverage("none");
// benefit.setAmount(0.00);
// benefit.setEnrolled(false);
//
// allEnrollments.add(benefit);
// }
}
return allEnrollments;
}
I tried various things with little to no success. Tried checking previous benefitDisplayTitle vs current one, tried flipping the if else. Seem to have gone down a rabbit hole.
Aucun commentaire:
Enregistrer un commentaire