1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.easymock.internal; |
18 |
|
|
19 |
|
import java.io.Serializable; |
20 |
|
import java.lang.reflect.Method; |
21 |
|
import java.util.HashMap; |
22 |
|
import java.util.Map; |
23 |
|
|
24 |
|
|
25 |
|
@author |
26 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (32) |
Complexity: 6 |
Complexity Density: 0,26 |
|
27 |
|
public class MethodSerializationWrapper implements Serializable { |
28 |
|
|
29 |
|
private static final long serialVersionUID = 1775475200823842126L; |
30 |
|
|
31 |
|
private static final Map<String, Class<?>> primitiveTypes = new HashMap<String, Class<?>>(10); |
32 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0,12 |
|
33 |
2
|
static {... |
34 |
2
|
primitiveTypes.put(Boolean.TYPE.getName(), Boolean.TYPE); |
35 |
2
|
primitiveTypes.put(Byte.TYPE.getName(), Byte.TYPE); |
36 |
2
|
primitiveTypes.put(Short.TYPE.getName(), Short.TYPE); |
37 |
2
|
primitiveTypes.put(Character.TYPE.getName(), Character.TYPE); |
38 |
2
|
primitiveTypes.put(Integer.TYPE.getName(), Integer.TYPE); |
39 |
2
|
primitiveTypes.put(Long.TYPE.getName(), Long.TYPE); |
40 |
2
|
primitiveTypes.put(Float.TYPE.getName(), Float.TYPE); |
41 |
2
|
primitiveTypes.put(Double.TYPE.getName(), Double.TYPE); |
42 |
|
} |
43 |
|
|
44 |
|
private final String className; |
45 |
|
|
46 |
|
private final String methodName; |
47 |
|
|
48 |
|
private final String[] parameterTypeNames; |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0,33 |
|
50 |
100
|
public MethodSerializationWrapper(final Method m) {... |
51 |
100
|
className = m.getDeclaringClass().getName(); |
52 |
100
|
methodName = m.getName(); |
53 |
|
|
54 |
100
|
final Class<?>[] parameterTypes = m.getParameterTypes(); |
55 |
|
|
56 |
100
|
parameterTypeNames = new String[parameterTypes.length]; |
57 |
|
|
58 |
154
|
for (int i = 0; i < parameterTypes.length; i++) { |
59 |
54
|
parameterTypeNames[i] = parameterTypes[i].getName(); |
60 |
|
} |
61 |
|
} |
62 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 3 |
Complexity Density: 0,33 |
|
63 |
100
|
public Method getMethod() throws ClassNotFoundException, NoSuchMethodException {... |
64 |
100
|
final Class<?> clazz = Class.forName(className, true, Thread.currentThread().getContextClassLoader()); |
65 |
|
|
66 |
100
|
final Class<?>[] parameterTypes = new Class[parameterTypeNames.length]; |
67 |
|
|
68 |
154
|
for (int i = 0; i < parameterTypeNames.length; i++) { |
69 |
54
|
final Class<?> primitiveType = primitiveTypes.get(parameterTypeNames[i]); |
70 |
54
|
if (primitiveType != null) { |
71 |
22
|
parameterTypes[i] = primitiveType; |
72 |
|
} else { |
73 |
32
|
parameterTypes[i] = Class.forName(parameterTypeNames[i], true, Thread.currentThread() |
74 |
|
.getContextClassLoader()); |
75 |
|
} |
76 |
|
} |
77 |
|
|
78 |
100
|
final Method m = clazz.getMethod(methodName, parameterTypes); |
79 |
|
|
80 |
100
|
return m; |
81 |
|
} |
82 |
|
} |