I have a structure like Map <String,List<Map<String,Object>>
. I want to apply a function to a map as follows. The method uses a key and uses a <String,Object>
list map . Each key has several cards <String,Object>
in the list. How to apply a process method to a map key for each map value <String,Object>
? I was able to use forEach loops (see below), but I have a feeling that this is not the best way to solve the problem in a functional way.
TypeProcessor p=new TypeProcessor.instance();
Result process(String key, Map<String,Object> dataPoints);
List<Result> list = new ArrayList<>();
map.forEach(key,value) -> {
value.forEach(innerVal -> {
Result r=p.process(key,innerVal);
list.add(r):
});
});
source
share