ReflectionUtil { public static ParameterizedType getParametrizedType(Class<?> clazz) { Type[] genericTypes = clazz.getGenericInterfaces(); for (Type type : genericTypes) { if (type instanceof ParameterizedType) { return (ParameterizedType) type; } } return null; } private  ReflectionUtil(); static ParameterizedType getParametrizedType(Class<?> clazz);  }
@Test public void testGetParametrizedType() throws Exception { Field stringListField = this.getClass().getDeclaredField("reflectable"); ParameterizedType genericListType = (ParameterizedType) stringListField.getGenericType(); assertThat(ReflectionUtil.getParametrizedType(reflectable.getClass()).toString()).isEqualTo(genericListType.toString()); assertThat(ReflectionUtil.getParametrizedType(multi.getClass()).getRawType().getTypeName()).isEqualTo(First.class.getName()); assertThat(ReflectionUtil.getParametrizedType(Object.class)).isNull(); }