View Javadoc

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