commit
e69d324b09
|
@ -657,7 +657,7 @@ public class ConcreteHandler1 extends Handler {
|
|||
|
||||
@Override
|
||||
protected void handleRequest(Request request) {
|
||||
if (request.getType() == RequestType.type1) {
|
||||
if (request.getType() == RequestType.TYPE1) {
|
||||
System.out.println(request.getName() + " is handle by ConcreteHandler1");
|
||||
return;
|
||||
}
|
||||
|
@ -676,7 +676,7 @@ public class ConcreteHandler2 extends Handler{
|
|||
|
||||
@Override
|
||||
protected void handleRequest(Request request) {
|
||||
if (request.getType() == RequestType.type2) {
|
||||
if (request.getType() == RequestType.TYPE2) {
|
||||
System.out.println(request.getName() + " is handle by ConcreteHandler2");
|
||||
return;
|
||||
}
|
||||
|
@ -709,7 +709,7 @@ public class Request {
|
|||
|
||||
```java
|
||||
public enum RequestType {
|
||||
type1, type2
|
||||
TYPE1, TYPE2
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -718,9 +718,9 @@ public class Client {
|
|||
public static void main(String[] args) {
|
||||
Handler handler1 = new ConcreteHandler1(null);
|
||||
Handler handler2 = new ConcreteHandler2(handler1);
|
||||
Request request1 = new Request(RequestType.type1, "request1");
|
||||
Request request1 = new Request(RequestType.TYPE1, "request1");
|
||||
handler2.handleRequest(request1);
|
||||
Request request2 = new Request(RequestType.type2, "request2");
|
||||
Request request2 = new Request(RequestType.TYPE2, "request2");
|
||||
handler2.handleRequest(request2);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user