Chain of Responsibility模式——读书笔记
继承如下抽象类的一系列类
abstract class Handler {
protected Handler next;
Handler(Handler next) {
this.next = next;
}
void doNext(char c) {
if(next != null) {
next.handle(c);
}
}
abstract void handle(char c);
}
多物件都有理求,除了可以自由合理求的物件之外,也可以避免求的送者接收者之的耦合,些物件合一,沿著求.
参考:http://caterpillar.onlyfun.net/Gossip/DesignPattern/ChainofResponsibility.htm