added chain of responsibility sample

This commit is contained in:
Ilkka Seppala
2014-08-17 09:05:37 +03:00
parent a53c217f37
commit 9e7db125a8
10 changed files with 189 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
package com.iluwatar;
public abstract class RequestHandler {
private RequestHandler next;
public RequestHandler(RequestHandler next) {
this.next = next;
}
public void handleRequest(Request req) {
if (next != null) {
next.handleRequest(req);
}
}
protected void printHandling(Request req) {
System.out.println(this + " handling request \"" + req + "\"");
}
@Override
public abstract String toString();
}