I have a Map<String, ? extends Collection<SomeClass>>. I would like to ensure that there are no entries where collection's size is 0. Therefore I tried myMap.values().stream().map(Collection::size).allMatch(size -> size > 0). However, as it turned out, myMap contains null entries.
I wanted to check if my map contains null entries: resourceMap.values().stream().noneMatch(null) but I got an Exception java.util.Objects.requireNonNull.
I decided to do it in a relatively old fashioned way, with a for-in loop for (Map.Entry<String, ? extends Collection> entry : myMap) However, I got a compilation error telling me that foreach is not applicable to my Map.
What is an elegant way to check if all entries in my map are not null and with size > 0?
.map(CollectionUtils::isNotEmpty)from commons-langfor each;)map.entrySet()and then iterate on map entry objects.