Advertisement
Guest User

Chain of responsibility

a guest
Oct 11th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. package chainofresponsibility.model.handler;
  2.  
  3. public abstract class Handler {
  4.    
  5.     private Handler     next;
  6.  
  7.     public Handler (){
  8.        
  9.     }
  10.    
  11.     public Handler (Handler next){
  12.         this.next = next;
  13.     }
  14.    
  15.     public void handleRequest (){
  16.         if (this.next != null){
  17.             this.next.handleRequest();
  18.         }
  19.         this.start();
  20.     }
  21.  
  22.     public abstract void start();
  23.    
  24.     public Handler setNext(Handler next){
  25.         this.next = next;
  26.         return this.next;
  27.     }
  28.    
  29.     public Handler getNext (){
  30.         return this.next;
  31.     }
  32.    
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement