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