|
1 |
| package com.agical.rmock.core.expectation.reference; |
|
2 |
| |
|
3 |
| import java.lang.reflect.Method; |
|
4 |
| import java.lang.reflect.Modifier; |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| public class BasicMethodReference implements MethodReference { |
|
12 |
| |
|
13 |
| private final Method method; |
|
14 |
| |
|
15 |
20
| public BasicMethodReference(Method method) {
|
|
16 |
20
| this.method = method;
|
|
17 |
| } |
|
18 |
| |
|
19 |
4
| public String getName() {
|
|
20 |
4
| return method.getName();
|
|
21 |
| } |
|
22 |
| |
|
23 |
3
| public Class getDeclaringClass() {
|
|
24 |
3
| return method.getDeclaringClass();
|
|
25 |
| } |
|
26 |
| |
|
27 |
3
| public Class getReturnType() {
|
|
28 |
3
| return method.getReturnType();
|
|
29 |
| } |
|
30 |
| |
|
31 |
4
| public String getAccessModifier() {
|
|
32 |
4
| if( Modifier.isPublic(method.getModifiers()) ) {
|
|
33 |
1
| return "public";
|
|
34 |
| } |
|
35 |
3
| if( Modifier.isPrivate(method.getModifiers()) ) {
|
|
36 |
1
| return "private";
|
|
37 |
| } |
|
38 |
2
| if( Modifier.isProtected(method.getModifiers()) ) {
|
|
39 |
1
| return "protected";
|
|
40 |
| } |
|
41 |
1
| return "";
|
|
42 |
| } |
|
43 |
| |
|
44 |
3
| public String getScope() {
|
|
45 |
3
| return Modifier.isStatic(method.getModifiers())?"static":"";
|
|
46 |
| } |
|
47 |
| |
|
48 |
3
| public String getSynchronized() {
|
|
49 |
3
| return Modifier.isSynchronized(method.getModifiers())?"synchronized":"";
|
|
50 |
| } |
|
51 |
| |
|
52 |
8
| public Class[] getParameterTypes() {
|
|
53 |
8
| return method.getParameterTypes();
|
|
54 |
| } |
|
55 |
| |
|
56 |
| } |