I am trying to use java 8 to return me a list of key values(Integers) in which the value (Checkbox) is checked. The map I am trying to process is of the following form.
Map<Integer, CheckBox>
The aim is to return the key set for all values where the check box value is checked.
If I do the following
checkBoxes.entrySet().stream().filter(c -> c.getValue().getValue())
.collect(Collectors.toList());
then I get back a List<Map.Entry<Integer, CheckBox>>
Is there anyway to do this all in one line without processing the Map.Entry values so I can just get a list of integers?
Thanks
You can add a
map
call to extract the key from the Entry :