I want to create method for combine Predicate::and in one predicate and submit it on input list. I have code:
public static List<?> getFilteredList(Collection<?> collection, Collection<Predicate<?>> filters) {
return collection.stream()
.filter(filters.stream().reduce(Predicate::and).orElse(t -> true))
.collect(Collectors.toList());
}
But compiler says that there is a error in Predicate::and Incompatible types: Predicate<capture of ?> is not convertible to Predicate<? super capture of ?>
How to fix it?