01 package net.sourceforge.pmd.util.filter;
02
03 /**
04 * A base class for Filters which implements behavior using delegation
05 * to an underlying filter.
06 *
07 * @param <T>
08 * The underlying type on which the filter applies.
09 */
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 }
|