01 package net.sourceforge.pmd.util.filter;
02
03 /**
04 * A logical AND of a list of Filters. This implementation is short circuiting.
05 *
06 * @param <T>
07 * The underlying type on which the filter applies.
08 */
09 public class AndFilter<T> extends AbstractCompoundFilter<T> {
10
11 public AndFilter() {
12 super();
13 }
14
15 public AndFilter(Filter<T>... filters) {
16 super(filters);
17 }
18
19 public boolean filter(T obj) {
20 boolean match = true;
21 for (Filter<T> filter : filters) {
22 if (!filter.filter(obj)) {
23 match = false;
24 break;
25 }
26 }
27 return match;
28 }
29
30 @Override
31 protected String getOperator() {
32 return "and";
33 }
34 }
|