blob: d2a1690325255cc9d4772cafc3c7a2b152fde7c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito.internal.util;
import java.lang.reflect.Method;
import org.mockito.internal.creation.DelegatingMethod;
import org.mockito.internal.invocation.MockitoMethod;
public class ObjectMethodsGuru{
private ObjectMethodsGuru() {
}
public static boolean isToStringMethod(Method method) {
MockitoMethod m = new DelegatingMethod(method);
return m.getReturnType() == String.class &&
m.getParameterTypes().length == 0 &&
"toString".equals(m.getName());
}
public static boolean isCompareToMethod(Method method) {
return Comparable.class.isAssignableFrom(method.getDeclaringClass())
&& "compareTo".equals(method.getName())
&& method.getParameterTypes().length == 1
&& method.getParameterTypes()[0] == method.getDeclaringClass();
}
}
|