View Javadoc

1   package net.sourceforge.pmd.util.filter;
2   
3   /**
4    * A logical AND 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 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  }