模式的定义 责任链模式定义如下: Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request.Chain the receiving objects and pass the request along the chain until an object handles it. 使多个对象都有机会处理请求,从而避免请求的发送
定义 Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request.Chain the receiving objects and pass the request along the chain until an object handles it.(使多个对象都有机会处理请求.从而避免了请求的发送者和接受者之间的耦合关系.
1.定义 避免请求发送者与接收者耦合在一起,让多个对象都有可能接收请求,将这些对象连接成一条链,并且沿着这条链传递请求,直到有对象处理它为止. 2.类图 3.代码示例 1 package com.zhaoyangwoo.chainOfResponsibility; 2 3 /** 4 * Created by john on 16/6/16. 5 * 职责链模式,经费审批场景 6 */ 7 public class Responsibility { 8 9 public static void