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 base class for Filters which implements behavior using delegation
8    * to an underlying filter.
9    * 
10   * @param <T>
11   *            The underlying type on which the filter applies.
12   */
13  public abstract class AbstractDelegateFilter<T> implements Filter<T> {
14  	protected Filter<T> filter;
15  
16  	public AbstractDelegateFilter() {
17  	}
18  
19  	public AbstractDelegateFilter(Filter<T> filter) {
20  		this.filter = filter;
21  	}
22  
23  	public Filter<T> getFilter() {
24  		return filter;
25  	}
26  
27  	public void setFilter(Filter<T> filter) {
28  		this.filter = filter;
29  	}
30  
31  	// Subclass should override to do something other the simply delegate.
32  	public boolean filter(T obj) {
33  		return filter.filter(obj);
34  	}
35  
36  	// Subclass should override to do something other the simply delegate.
37  	public String toString() {
38  		return filter.toString();
39  	}
40  }