0

I need to count the elements in the next list I have a listArtif list and for each of their elements I have a list of findings and for each of the findings objects I have a field called isChecked, so I need to count all the checked findings in the listArtif list. I've done the next but I'm getting the total of elements in the listArtif list.

artifactList.stream().map(artifact -> artList.getFindings().stream().filter(finding -> finding.isChecked()).count());

Any ideas?

Thanks!

1 Answer 1

3

I think you are looking for something like

artifactList.stream()
            .flatMap(artifact -> artifact.getFindings().stream())
            .filter(finding -> finding.isChecked())
            .count();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.