If this is a recurring problem, you can create a helper method that generalizes the task of decorating a predicate with another action, for example. logging:
static <T> Predicate<T> logging(Predicate<T> p, BiConsumer<T,Boolean> log, boolean all) {
return t -> {
final boolean result = p.test(t);
if(all || result) log.accept(t, result);
return result;
};
}
which you can use as
public void testMethod(List<String> prop1, EmailJson randomModel){
prop1.forEach(s -> randomModel.getSomeList()
.removeIf(logging(model -> model.getSomeProp().equalsIgnoreCase(s),
(model,b) -> LOGGER.info(() -> "matched: "+model.getSomeProp()), false)));
}
although in this particular case, it may not be necessary to decorate the predicate itself, since it removeIfreturns a boolean, indicating whether matches have been deleted, and the match value is still in scope:
public void testMethod(List<String> prop1, EmailJson randomModel){
prop1.stream().forEach(s -> {
if(randomModel.getSomeList()
.removeIf(model -> model.getSomeProp().equalsIgnoreCase(s)))
LOGGER.info(() -> "there were matches of: "+s);
});
}