01: package junit.support;
02:
03: import java.lang.reflect.Method;
04: import java.util.Arrays;
05: import java.util.Collections;
06: import java.util.List;
07:
08: /**
09: * Helper class that encapsulates a {@link Method} and a {@link List} of Objects denoting parameters to the method.
10: * Collectively, they describe a method invocation.
11: *
12: * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
13: */
14: public class MethodInvocation {
15: private List params;
16:
17: public List getParams() {
18: return params;
19: }
20:
21: public Method getMethod() {
22: return method;
23: }
24:
25: private Method method;
26:
27: public MethodInvocation(Method method, Object... params) {
28: this .params = params == null ? Collections.emptyList() : Arrays
29: .asList(params);
30: this .method = method;
31: }
32:
33: public boolean equals(Object o) {
34: if (this == o)
35: return true;
36: if (o == null || getClass() != o.getClass())
37: return false;
38:
39: MethodInvocation event = (MethodInvocation) o;
40:
41: if (method != null ? !method.equals(event.method)
42: : event.method != null)
43: return false;
44: if (params != null ? !params.equals(event.params)
45: : event.params != null)
46: return false;
47:
48: return true;
49: }
50:
51: public int hashCode() {
52: int result;
53: result = (params != null ? params.hashCode() : 0);
54: result = 31 * result + (method != null ? method.hashCode() : 0);
55: return result;
56: }
57: }
|