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.