Java Reconstruct data structure using lambda expression

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;
     .map(a -> a.getListB()) // extract list B from A
     .flatMap(Collection::stream) // Here you get all B instances
            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

Leave a Comment