TypeLiteral implements Serializable { public static Type[] getGenericInterfaceTypeParameters(Class<?> clazz, Class<?> interfaceType) { Objects.requireNonNull(clazz, "Class parameter must be given."); Objects.requireNonNull(interfaceType, "Interface parameter must be given."); for (Type type : clazz.getGenericInterfaces()) { if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; if(parameterizedType.getRawType().equals(interfaceType)){ return parameterizedType.getActualTypeArguments(); } } } return EMPTY_TYPE_ARRAY; } TypeLiteral(Type definedType);  TypeLiteral(); static TypeLiteral<R> of(Type type); static Type[] getGenericInterfaceTypeParameters(Class<?> clazz, Class<?> interfaceType); static Type[] getTypeParameters(Type type); final Type getType(); @SuppressWarnings("unchecked") final Class<T> getRawType(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void test_getGenericInterfaceTypeParameter() { class MyListClass extends ArrayList<String> implements List<String> { } assertThat(getGenericInterfaceTypeParameters(MyListClass.class, List.class)[0]).isEqualTo(String.class); }
@Test public void testGetGenericInterfaceTypeParameterNoGenerics() { assertThat(getGenericInterfaceTypeParameters(String.class, String.class).length).isEqualTo(0); }
@Test(expected = NullPointerException.class) public void getGenericInterfaceTypeParametersRequiredNonNullValueForClassParameter() { getGenericInterfaceTypeParameters(null, Iterator.class); }
@Test(expected = NullPointerException.class) public void getGenericInterfaceTypeParametersRequiredNonNullValueForInterfaceParameter() { getGenericInterfaceTypeParameters(String.class, null); }