If I understand you correctly, here's a solution:
Suppose we have this data:
Map<String, List<Integer>> map = new HashMap<>();
map.put("Noo", new ArrayList<>(Arrays.asList(8,8,9)));
map.put("No", new ArrayList<>(Arrays.asList(1,8,9)));
map.put("Aoo", new ArrayList<>(Arrays.asList(8,8,9)));
We can filter the data in this way:
map.entrySet().
stream()
.filter(e -> e.getKey().startsWith("N"))
.filter(e -> e.getValue().stream().filter(id -> id <= 7).findAny().orElse(0) == 0)
.map(Map.Entry::getKey)
.collect(Collectors.toSet());
The first filter excludes the Names that does not start with "N"
, the second filter goes through the remaining entries and check if all their ids
are greater than 7. In the foreach I just print the data, but you can change the logic to your needs
The result should the this:
Noo [8, 8, 9]