public class Chain {
private List<Interceptor> interceptors = new ArrayList<>();
private Param param;
public void proceed() {
for (Interceptor interceptor : interceptors) {
if (interceptor.intercept(this)) {
break;
}
}
}
public void proceedNext(Interceptor interceptor) {
int index = interceptors.indexOf(interceptor);
if (index != -1) {
for (int i = ++index; i < interceptors.size(); ++i) {
interceptor = interceptors.get(i);
if (interceptor.intercept(this)) {
break;
}
}
}
}
... ...
}