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 OR 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 OrFilter<T> extends AbstractCompoundFilter<T> {
13  
14  	public OrFilter() {
15  		super();
16  	}
17  
18  	public OrFilter(Filter<T>... filters) {
19  		super(filters);
20  	}
21  
22  	public boolean filter(T obj) {
23  		boolean match = false;
24  		for (Filter<T> filter : filters) {
25  			if (filter.filter(obj)) {
26  				match = true;
27  				break;
28  			}
29  		}
30  		return match;
31  	}
32  
33  	@Override
34  	protected String getOperator() {
35  		return "or";
36  	}
37  }