@Test public void testGetMostSpecificMethod() throws Exception { final Method mObject = getClass().getDeclaredMethod("setThreeAccessibleNoExactMatchSetter", Object.class); final Method mThrowable = getClass().getDeclaredMethod("setThreeAccessibleNoExactMatchSetter", Throwable.class); final Method mException = getClass().getDeclaredMethod("setThreeAccessibleNoExactMatchSetter", Exception.class); assertEquals(mThrowable, Util.getMostSpecificMethod(mObject, mThrowable)); assertEquals(mException, Util.getMostSpecificMethod(mException, mThrowable)); assertEquals(mException, Util.getMostSpecificMethod(mException, mObject)); }
public static Method getMostSpecificMethod(final Method method1, final Method method2) { final Class<?> class1 = method1.getParameterTypes()[0]; final Class<?> class2 = method2.getParameterTypes()[0]; if (class1.isAssignableFrom(class2)) { return method2; } else { return method1; } }
Util { public static Method getMostSpecificMethod(final Method method1, final Method method2) { final Class<?> class1 = method1.getParameterTypes()[0]; final Class<?> class2 = method2.getParameterTypes()[0]; if (class1.isAssignableFrom(class2)) { return method2; } else { return method1; } } }
Util { public static Method getMostSpecificMethod(final Method method1, final Method method2) { final Class<?> class1 = method1.getParameterTypes()[0]; final Class<?> class2 = method2.getParameterTypes()[0]; if (class1.isAssignableFrom(class2)) { return method2; } else { return method1; } } private  Util(); }
Util { public static Method getMostSpecificMethod(final Method method1, final Method method2) { final Class<?> class1 = method1.getParameterTypes()[0]; final Class<?> class2 = method2.getParameterTypes()[0]; if (class1.isAssignableFrom(class2)) { return method2; } else { return method1; } } private  Util(); static boolean isInstance(final Class type, final Object instance); static void addProperty(final Hashtable env, String property); static Method findSetter(final Class<?> testClazz, final Field field, final Object propertyValue); static Method getMostSpecificMethod(final Method method1, final Method method2); }
Util { public static Method getMostSpecificMethod(final Method method1, final Method method2) { final Class<?> class1 = method1.getParameterTypes()[0]; final Class<?> class2 = method2.getParameterTypes()[0]; if (class1.isAssignableFrom(class2)) { return method2; } else { return method1; } } private  Util(); static boolean isInstance(final Class type, final Object instance); static void addProperty(final Hashtable env, String property); static Method findSetter(final Class<?> testClazz, final Field field, final Object propertyValue); static Method getMostSpecificMethod(final Method method1, final Method method2);  }