1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.callbackparams.support;
18
19 import org.apache.bcel.classfile.Method;
20 import org.apache.bcel.generic.ClassGen;
21 import org.apache.bcel.generic.Type;
22
23
24
25
26
27
28
29
30
31
32
33 public class MethodHashKey {
34
35 private final String className;
36 final String methodName;
37 private final String signature;
38
39 public MethodHashKey(String className, String methodName, String signature){
40 this.className = className;
41 this.methodName = methodName;
42 this.signature = signature;
43 }
44
45 public static MethodHashKey getHashKey(java.lang.reflect.Method m) {
46 return new MethodHashKey(m.getDeclaringClass().getName(),
47 m.getName(), Type.getSignature(m));
48 }
49
50 public static MethodHashKey getHashKey(ClassGen cg, Method m) {
51 return new MethodHashKey(cg.getClassName(),
52 m.getName(), m.getSignature());
53 }
54
55 public boolean equals(Object obj) {
56 if (obj == null) {
57 return false;
58 }
59 if (getClass() != obj.getClass()) {
60 return false;
61 }
62 final MethodHashKey other = (MethodHashKey) obj;
63 if ((this.className == null) ? (other.className != null) : !this.className.equals(other.className)) {
64 return false;
65 }
66 if ((this.methodName == null) ? (other.methodName != null) : !this.methodName.equals(other.methodName)) {
67 return false;
68 }
69 if ((this.signature == null) ? (other.signature != null) : !this.signature.equals(other.signature)) {
70 return false;
71 }
72 return true;
73 }
74
75 public int hashCode() {
76 int hash = 3;
77 hash = 53 * hash + (this.className != null ? this.className.hashCode() : 0);
78 hash = 53 * hash + (this.methodName != null ? this.methodName.hashCode() : 0);
79 hash = 53 * hash + (this.signature != null ? this.signature.hashCode() : 0);
80 return hash;
81 }
82 }