@Test public void testInfer() { SecondTestListener victim = new SecondTestListener(); assertEquals(PercentageOfWorkDoneChangedEvent.class, ReflectionUtils.inferParameterClass(victim.getClass(), "onEvent")); }
@SuppressWarnings("rawtypes") public static Class inferParameterClass(Class clazz, String methodName) { Method[] methods = clazz.getMethods(); for (Method method : methods) { if (method.getName().equals(methodName) && !method.isBridge()) { Type[] types = method.getGenericParameterTypes(); for (Type type : types) { if (type instanceof Class && !((Class) type).isInterface()) { return (Class) type; } } } } return null; }
ReflectionUtils { @SuppressWarnings("rawtypes") public static Class inferParameterClass(Class clazz, String methodName) { Method[] methods = clazz.getMethods(); for (Method method : methods) { if (method.getName().equals(methodName) && !method.isBridge()) { Type[] types = method.getGenericParameterTypes(); for (Type type : types) { if (type instanceof Class && !((Class) type).isInterface()) { return (Class) type; } } } } return null; } }
ReflectionUtils { @SuppressWarnings("rawtypes") public static Class inferParameterClass(Class clazz, String methodName) { Method[] methods = clazz.getMethods(); for (Method method : methods) { if (method.getName().equals(methodName) && !method.isBridge()) { Type[] types = method.getGenericParameterTypes(); for (Type type : types) { if (type instanceof Class && !((Class) type).isInterface()) { return (Class) type; } } } } return null; } private  ReflectionUtils(); }
ReflectionUtils { @SuppressWarnings("rawtypes") public static Class inferParameterClass(Class clazz, String methodName) { Method[] methods = clazz.getMethods(); for (Method method : methods) { if (method.getName().equals(methodName) && !method.isBridge()) { Type[] types = method.getGenericParameterTypes(); for (Type type : types) { if (type instanceof Class && !((Class) type).isInterface()) { return (Class) type; } } } } return null; } private  ReflectionUtils(); @SuppressWarnings("rawtypes") static Class inferParameterClass(Class clazz, String methodName); }
ReflectionUtils { @SuppressWarnings("rawtypes") public static Class inferParameterClass(Class clazz, String methodName) { Method[] methods = clazz.getMethods(); for (Method method : methods) { if (method.getName().equals(methodName) && !method.isBridge()) { Type[] types = method.getGenericParameterTypes(); for (Type type : types) { if (type instanceof Class && !((Class) type).isInterface()) { return (Class) type; } } } } return null; } private  ReflectionUtils(); @SuppressWarnings("rawtypes") static Class inferParameterClass(Class clazz, String methodName);  }