We are doing some chained filters to evaluate a bunch of expressions to get only the items that match all the expressions. It looks something like this:
getItems().stream()
.filter(Item::isActive)
.filter(item -> fulfillsConditionA(item))
.filter(item -> item.getSomeNumber() < anyOtherNumber)
.forEach(item -> doSomeStuff(item));
While this works as expected, there is no way to see/log what specific filter predicate filtered out an item.
Is there a way to get the unmatched elements of a filter()
call, or is there a way to add a Consumer
or Function
as a second parameter to the filter()
call which is executed when the filter
does not match?