Does the String
in Map<String, List<A>>
related to the output? I assume that you want to get every pair <F, E>
from the original map right? So this might help
Map<String, List<A>> input;
input.values().stream()
.flatMap(Collection::stream)
.map(a -> a.getListB()) // extract list B from A
.flatMap(Collection::stream) // Here you get all B instances
.collect(
toMap(
b -> b.getD().getF(), b -> b.getC().getE(),
(e1, e2) -> ??? // Here you should define your own merge function if there are two B instances has same F values
)
);
3
solved Java Reconstruct data structure using lambda expression