Source:
public void validate(PendingCertifiedProductDTO product) { super.validate(product); boolean hasG1Cert = false; for (PendingCertificationResultDTO certCriteria : product.getCertificationCriterion()) { if (certCriteria.getNumber().equals("170.314 (g)(1)") && certCriteria.getMeetsCriteria()) { hasG1Cert = true; } } if (hasG1Cert) { String[] g1Certs = getG1ComplimentaryCerts(); boolean hasG1Complement = false; for (int i = 0; i < g1Certs.length && !hasG1Complement; i++) { for (PendingCertificationResultDTO certCriteria : product.getCertificationCriterion()) { if (certCriteria.getNumber().equals(g1Certs[i]) && certCriteria.getMeetsCriteria()) { hasG1Complement = true; } } } if (!hasG1Complement) { product.getErrorMessages().add("(g)(1) was found without a required related certification."); } } boolean hasG2Cert = false; for (PendingCertificationResultDTO certCriteria : product.getCertificationCriterion()) { if (certCriteria.getNumber().equals("170.314 (g)(2)") && certCriteria.getMeetsCriteria()) { hasG2Cert = true; } } if (hasG2Cert) { String[] g2Certs = getG2ComplimentaryCerts(); boolean hasG2Complement = false; for (int i = 0; i < g2Certs.length && !hasG2Complement; i++) { for (PendingCertificationResultDTO certCriteria : product.getCertificationCriterion()) { if (certCriteria.getNumber().equals(g2Certs[i]) && certCriteria.getMeetsCriteria()) { hasG2Complement = true; } } } if (!hasG2Complement) { product.getErrorMessages().add("(g)(2) was found without a required related certification."); } } if (hasG1Cert && hasG2Cert) { product.getErrorMessages().add("Both (g)(1) and (g)(2) were found which is not typically permitted."); } }

Target:
public void validate(PendingCertifiedProductDTO product) { super.validate(product); boolean hasG1Cert = false; for (PendingCertificationResultDTO certCriteria : product.getCertificationCriterion()) { if (certCriteria.getNumber().equals("170.314 (g)(1)") && certCriteria.getMeetsCriteria()) { hasG1Cert = true; } } if (hasG1Cert) { String[] g1Certs = getG1ComplimentaryCerts(); boolean hasG1Complement = false; for (int i = 0; i < g1Certs.length && !hasG1Complement; i++) { for (PendingCertificationResultDTO certCriteria : product.getCertificationCriterion()) { if (certCriteria.getNumber().equals(g1Certs[i]) && certCriteria.getMeetsCriteria()) { hasG1Complement = true; } } } if (!hasG1Complement) { product.getErrorMessages().add(getErrorMessage("listing.criteria.missingG1Related")); } } boolean hasG2Cert = false; for (PendingCertificationResultDTO certCriteria : product.getCertificationCriterion()) { if (certCriteria.getNumber().equals("170.314 (g)(2)") && certCriteria.getMeetsCriteria()) { hasG2Cert = true; } } if (hasG2Cert) { String[] g2Certs = getG2ComplimentaryCerts(); boolean hasG2Complement = false; for (int i = 0; i < g2Certs.length && !hasG2Complement; i++) { for (PendingCertificationResultDTO certCriteria : product.getCertificationCriterion()) { if (certCriteria.getNumber().equals(g2Certs[i]) && certCriteria.getMeetsCriteria()) { hasG2Complement = true; } } } if (!hasG2Complement) { product.getErrorMessages().add(getErrorMessage("listing.criteria.missingG2Related")); } } if (hasG1Cert && hasG2Cert) { product.getErrorMessages().add(getErrorMessage("listing.criteria.G1G2Found")); } }