### Question:
ReflectUtils { public static Class<?> getGenericClass(Class<?> cls) { return getGenericClass(cls, 0); } private  ReflectUtils(); static boolean isPrimitives(Class<?> cls); static boolean isPrimitive(Class<?> cls); static Class<?> getBoxedClass(Class<?> c); static boolean isCompatible(Class<?> c, Object o); static boolean isCompatible(Class<?>[] cs, Object[] os); static String getCodeBase(Class<?> cls); static String getName(Class<?> c); static Class<?> getGenericClass(Class<?> cls); static Class<?> getGenericClass(Class<?> cls, int i); static String getName(final Method m); static String getSignature(String methodName, Class<?>[] parameterTypes); static String getName(final Constructor<?> c); static String getDesc(Class<?> c); static String getDesc(final Class<?>[] cs); static String getDesc(final Method m); static String getDesc(final Constructor<?> c); static String getDescWithoutMethodName(Method m); static String getDesc(final CtClass c); static String getDesc(final CtMethod m); static String getDesc(final CtConstructor c); static String getDescWithoutMethodName(final CtMethod m); static String name2desc(String name); static String desc2name(String desc); static Class<?> forName(String name); static Class<?> forName(ClassLoader cl, String name); static Class<?> name2class(String name); static Class<?> desc2class(String desc); static Class<?>[] desc2classArray(String desc); static Method findMethodByMethodSignature(Class<?> clazz, String methodName, String[] parameterTypes); static Method findMethodByMethodName(Class<?> clazz, String methodName); static Constructor<?> findConstructor(Class<?> clazz, Class<?> paramType); static boolean isInstance(Object obj, String interfaceClazzName); static Object getEmptyObject(Class<?> returnType); static boolean isBeanPropertyReadMethod(Method method); static String getPropertyNameFromBeanReadMethod(Method method); static boolean isBeanPropertyWriteMethod(Method method); static String getPropertyNameFromBeanWriteMethod(Method method); static boolean isPublicInstanceField(Field field); static Map<String, Field> getBeanPropertyFields(Class cl); static Map<String, Method> getBeanPropertyReadMethods(Class cl); static final char JVM_VOID; static final char JVM_BOOLEAN; static final char JVM_BYTE; static final char JVM_CHAR; static final char JVM_DOUBLE; static final char JVM_FLOAT; static final char JVM_INT; static final char JVM_LONG; static final char JVM_SHORT; static final Class<?>[] EMPTY_CLASS_ARRAY; static final String JAVA_IDENT_REGEX; static final String JAVA_NAME_REGEX; static final String CLASS_DESC; static final String ARRAY_DESC; static final String DESC_REGEX; static final Pattern DESC_PATTERN; static final String METHOD_DESC_REGEX; static final Pattern METHOD_DESC_PATTERN; static final Pattern GETTER_METHOD_DESC_PATTERN; static final Pattern SETTER_METHOD_DESC_PATTERN; static final Pattern IS_HAS_CAN_METHOD_DESC_PATTERN; }### Answer:
@Test public void testGetGenericClass() throws Exception { assertThat(ReflectUtils.getGenericClass(Foo1.class), sameInstance(String.class)); }
@Test public void testGetGenericClassWithIndex() throws Exception { assertThat(ReflectUtils.getGenericClass(Foo1.class, 0), sameInstance(String.class)); assertThat(ReflectUtils.getGenericClass(Foo1.class, 1), sameInstance(Integer.class)); assertThat(ReflectUtils.getGenericClass(Foo2.class, 0), sameInstance(List.class)); assertThat(ReflectUtils.getGenericClass(Foo2.class, 1), sameInstance(int.class)); assertThat(ReflectUtils.getGenericClass(Foo3.class, 0), sameInstance(Foo1.class)); assertThat(ReflectUtils.getGenericClass(Foo3.class, 1), sameInstance(Foo2.class)); }