定义
使多个对象都有机会处理请求,从而避免请求的发送者和接收者之间的耦合关系。将这些对象连成一条链,并沿着这条链发送该请求,直到有一个对象处理它为止。
数据结构
demo
1 | public abstract class Handler { |
1 | public class ConcreteHandler1 extends Handler { |
1 | public class ConcreteHandler2 extends Handler { |
1 | public class Request { |
1 | public enum RequestType { |
1 | public class Client { |
1
2
3 > request1 is handle by ConcreteHandler1
> request2 is handle by ConcreteHandler2
>