how would you refactor this code into Streams?
for (ConditionEntity conditionEntity : dbData.getContent()) {
AdminCondition adminCondition =
dataEntityMapper.conditionEntitytoModel(conditionEntity);
this.myService.addBasicInterest(adminCondition); // <=== this is my Problem
conditionList.add(adminCondition);
}
I've this so far:
dbData.getContent().stream()
.map(conditionEntity -> dataEntityMapper.conditionEntitytoModel(conditionEntity))
.collect(conditionList);
Thx for help!
I would prefer the following solution:
List<ConditionEntity> conditions = dbData.getContent().stream()
.map(dataEntityMapper::conditionEntitytoModel)
.collect(Collectors.toList());
conditions.forEach(this::addBasicInterest);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With