rails rails - 1 year ago 62
Java Question

java streams - collect elements from map of collections using condition on the values

I have a Map. Let's say

Map<Long, List<MyObj>>

I want to collect all the long values (keys)

when at least one myObj answers


using java stream.

I tried


Answer Source
List<Long> keys = map.entrySet()
        .filter(e -> e.getValue().stream().anyMatch(o -> !o.isEnabled()))