0

I got a map from my database, this map is as follows:

{70007564=[PensionMediumView : {mtBrutPension=10480.32, quartierId=LS, typePensionId=21, destinataireBulletin=1, txPensionRetenu=40.5,}]}

I try to display an error message if I find that the "typePensionId=21" (key number 3) by loop for. I used the following code:

final Long idBeneficiaire = context.getIdPersonne();
        final Map<Long, List<PensionMediumView>> mapPensionsBeneficiaire = this.pensionBusinessApplicatif
            .recupererPensionsActivesParBeneficiaires(Arrays.asList(idBeneficiaire), context.getIdentificationContext());
    for (final Map.Entry<Long, List<PensionMediumView>> entry : mapPensionsBeneficiaire.entrySet()){
......
}

how can i display an error message if i find that "typePensionId=21"

sami
  • 3
  • 2

1 Answers1

0

I believe from your question that this is the sort of thing you're looking for. As i commented by the if statement, i wasn't sure exactly how to get the pension type id from looking at your example. Hopefully this helps.

final Long idBeneficiaire = context.getIdPersonne();
final Map<Long, List<PensionMediumView>> mapPensionsBeneficiaire = this.pensionBusinessApplicatif
    .recupererPensionsActivesParBeneficiaires(
    Arrays.asList(idBeneficiaire),
    context.getIdentificationContext());
for (final Map.Entry<Long, List<PensionMediumView>> entry : mapPensionsBeneficiaire.entrySet()){
    for(PensionMediumView pension : enter.getValue()) {
        // I wasn't sure of how to get the pension id from your example
        // So just replace this with example getter with however you get your pension ID
        if(pension.typePensionId() == 21) {
            System.out.println("Error!");
            break; // This will stop the loop, 
            // if you want the loop to continue, don't use this
        }
    }
}
vpaladino778
  • 157
  • 14