1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package org.perfectjpattern.core.behavioral.chainofresponsibility; |
22 |
|
|
23 |
|
import org.apache.commons.lang.*; |
24 |
|
import org.perfectjpattern.core.api.behavioral.chainofresponsibility.*; |
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
@see |
35 |
|
@see |
36 |
|
|
37 |
|
@param |
38 |
|
|
39 |
|
@author |
40 |
|
@version |
41 |
|
|
42 |
|
public abstract |
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 8 |
Complexity Density: 0.67 |
|
43 |
|
class AbstractHandler<R> |
44 |
|
implements IHandler<R> |
45 |
|
{ |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
52 |
22
|
@SuppressWarnings("unchecked")... |
53 |
|
public |
54 |
|
AbstractHandler() |
55 |
|
{ |
56 |
22
|
theSuccessor = (IHandler<R>) NullHandler.getInstance(); |
57 |
|
} |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
@param |
64 |
|
@throws |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
66 |
4
|
public ... |
67 |
|
AbstractHandler(IHandler<R> aSuccessor) |
68 |
|
throws IllegalArgumentException |
69 |
|
{ |
70 |
4
|
Validate.notNull(aSuccessor, "'aSuccessor' must not be null"); |
71 |
|
|
72 |
4
|
theSuccessor = aSuccessor; |
73 |
|
} |
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
@inheritDoc |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
79 |
24
|
@SuppressWarnings("unchecked")... |
80 |
|
public final void |
81 |
|
start(R aRequest) |
82 |
|
throws IllegalArgumentException |
83 |
|
{ |
84 |
24
|
IHandler<Object> myHandler = (IHandler<Object>) this; |
85 |
|
|
86 |
24
|
theStrategy.process(myHandler, aRequest); |
87 |
|
} |
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
@inheritDoc |
92 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
93 |
18
|
public final IHandler<R>... |
94 |
|
getSuccessor() |
95 |
|
{ |
96 |
18
|
return theSuccessor; |
97 |
|
} |
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
@inheritDoc |
102 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
103 |
16
|
public boolean ... |
104 |
|
canHandle(R aRequest) |
105 |
|
throws IllegalArgumentException |
106 |
|
{ |
107 |
16
|
return true; |
108 |
|
} |
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
@inheritDoc |
113 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
114 |
8
|
public void... |
115 |
|
handle(R aRequest) |
116 |
|
throws IllegalArgumentException |
117 |
|
{ |
118 |
8
|
Validate.notNull(aRequest, "'aRequest' must not be null"); |
119 |
8
|
Validate.isTrue(canHandle(aRequest), "'aRequest' can not be handled."); |
120 |
|
} |
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
@inheritDoc |
125 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
126 |
16
|
public final void ... |
127 |
|
setSuccessor(IHandler<R> aSuccessor) |
128 |
|
throws IllegalArgumentException |
129 |
|
{ |
130 |
16
|
Validate.notNull(aSuccessor, "'aSuccessor' must not be null"); |
131 |
|
|
132 |
16
|
theSuccessor = aSuccessor; |
133 |
|
} |
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
@inheritDoc |
138 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
139 |
15
|
public final void ... |
140 |
|
setChainStrategy(IChainStrategy aStrategy) |
141 |
|
throws IllegalArgumentException |
142 |
|
{ |
143 |
15
|
theStrategy = aStrategy; |
144 |
|
} |
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
private IHandler<R> theSuccessor; |
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
private IChainStrategy theStrategy = OnlyOneHandleStrategy.getInstance(); |
159 |
|
} |