I want to change the following code to use Streams, but I didn't find a similar example.
Map<Integer, DspInfoEntity> dspInfoEntityMap = dspInfoService.getDspInfoEntityMap();
List<DspInfoEntity> dspInfoList = new ArrayList<>();
for (AppLaunchMappingDto appLaunchMappingDto : appLaunchMappingDtoList) {
int dspId = appLaunchMappingDto.getDspId();
if (dspInfoEntityMap.containsKey(dspId)) {
dspInfoList.add(dspInfoEntityMap.get(dspId));
}
}
I think it could be like this:
List<DspInfoEntity> dspInfoList = dspInfoEntityMap.entrySet().stream().filter(?).collect(Collectors.toList());
Listnot over aMapindspInfoEntityMap.entrySet()or I'm wrong with that?filter(dspInfoEntityMap::containsKey).mapToObj(dspInfoEntityMap::get)?