### Question:
Generics { public static Type getGenericClassType(Object instance, Class<?> clazz, int position) { Class<?> type = instance.getClass(); while (type != Object.class) { if (type.getGenericSuperclass() instanceof ParameterizedType) { ParameterizedType genericSuperclass = (ParameterizedType) type.getGenericSuperclass(); if (genericSuperclass.getRawType() == clazz) { return genericSuperclass.getActualTypeArguments()[position]; } else { type = type.getSuperclass(); } } else { type = type.getSuperclass(); } } return null; } private  Generics(); static Type getGenericClassType(Object instance, Class<?> clazz, int position); static Type getGenericInterfaceType(Object instance, Class<?> iface, int position);  }### Answer:
@Test public void testGetClassType() throws Exception { assertEquals(SomeClass.class, Generics.getGenericClassType(new ConcreteClass(), GenericClass.class, 0)); }