简单的拦截器模式实现
拦截器模式,是用巧妙的递归实现拦截功能的。
类图结构如:
代码实现:
接口:interceptor:
import java.util.List;
public interface Interceptor {
public List<String> interceptor(TargetInterceptor targetInterceptor);
}
接口Target:
public interface Target {
public List<String> excute(int count);
}
实现一下
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class TargetInterceptor {
private List<Interceptor> interceptorList = new ArrayList<Interceptor>();
private Iterator<Interceptor> interceptors;
private int count;
private Ta