Merges a collection of predicates into a single predicate, which requires the subject to match at least one of the component predicates.
(Iterable<? extends Predicate<? super T>> components)
| 29 | * which requires the subject to match at least one of the component predicates. |
| 30 | */ |
| 31 | public static <T> Predicate<T> or(Iterable<? extends Predicate<? super T>> components) { |
| 32 | if(components instanceof List && ((List<?>) components).size() == 1) |
| 33 | return ((List<? extends Predicate<? super T>>) components).get(0)::test; |
| 34 | return x -> any(components, i -> i.test(x)); |
| 35 | } |
| 36 | |
| 37 | public static <T> Iterable<T> filter(Iterable<T> iterable, Predicate<? super T> filter) { |
| 38 | return () -> StreamSupport.stream(iterable.spliterator(), false).filter(filter).iterator(); |
no test coverage detected