123456789101112131415161718 |
- package responsibilityPattern.handler;
- import responsibilityPattern.entity.Order;
- public abstract class OrderHandler {
- private OrderHandler nextHandler;
- public OrderHandler setNextHandler(OrderHandler nextHandler) {
- this.nextHandler = nextHandler;
- return nextHandler;
- }
- public void handle(Order order) throws Exception {
- if(proceed(order)&&nextHandler != null) {
- nextHandler.handle(order);
- }
- }
- abstract boolean proceed(Order order) throws Exception;
- }
|