Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this class
public class InsurancePackageCovers  {
    ProgramRef programId;
    PackageRef id;
    Set<InsuranceCover> covers;

    InsurancePackageCovers(ProgramRef programId ,PackageRef id,Set<InsuranceCover> covers) {
        this.programId = programId;
        this.id=id;
        this.covers = covers;
    }


and this map
Map<ProgramRef,Map<PackageRef, Set<InsuranceCover>>>allProgramPackages


I would like to stream the map to resemble something like

Map<ProgramRef,Map<PackageRef, Set<InsuranceCover>>>allProgramPackages = this.packageCoverRepository.getInsurancePackageCoversByProgramIds(programsToValidate)
               .stream()
               .collect(Collectors.toMap(
                       InsurancePackageCovers::getProgramId,
                               entrySet()
                               .stream()
                               .collect(
                                       Collectors.toMap(
                                               InsurancePackageCovers::getId,
                                               InsurancePackageCovers::getCovers
                                       )
                               )
               );



where
programref is rep by InsurancePackageCovers::getProgramId,  PackageRef by InsurancePackageCovers::getId and Set<InsuranceCover> by  InsurancePackageCovers::getCovers


What I have tried:

New to nested maps so basically stuck.
Posted
Updated 20-Oct-20 0:07am
v2
Comments
Richard MacCutchan 20-Oct-20 4:08am    
What is the question?
Richard MacCutchan 20-Oct-20 4:43am    
Please use the Improve question link above and add proper complete details of what you are trying to do, and what is not working.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900