1 package net.sourceforge.pmd.util.filter;
2
3 /**
4 * A logical OR of a list of Filters. This implementation is short circuiting.
5 *
6 * @param <T>
7 * The underlying type on which the filter applies.
8 */
9 public class OrFilter<T> extends AbstractCompoundFilter<T> {
10
11 public OrFilter() {
12 super();
13 }
14
15 public OrFilter(Filter<T>... filters) {
16 super(filters);
17 }
18
19 public boolean filter(T obj) {
20 boolean match = false;
21 for (Filter<T> filter : filters) {
22 if (filter.filter(obj)) {
23 match = true;
24 break;
25 }
26 }
27 return match;
28 }
29
30 @Override
31 protected String getOperator() {
32 return "or";
33 }
34 }