Types { public static boolean isTypeVariable(TypeToken<?> type) { return type.getType() instanceof TypeVariable; }  static boolean isArrayType(TypeToken<?> type); static boolean isEnumType(TypeToken<?> type); static boolean isMapType(TypeToken<?> type); static boolean isConcreteType(Type type); static boolean isJavaClientEntity(TypeToken<?> type); static boolean isTypeVariable(TypeToken<?> type); static boolean isCollectionResponseType(TypeToken<?> type); static boolean isWildcardType(TypeToken<?> type); static boolean isObject(TypeToken<?> type); static String getSimpleName(TypeToken<?> type, ApiSerializationConfig config); static TypeToken<?> getArrayItemType(TypeToken<?> type); static TypeToken<?> getTypeParameter(TypeToken<?> type, int index);  }
@Test public void isTypeVariable() throws Exception { final class Foo<T> { @SuppressWarnings("unused") void foo(T t) {} } assertThat(Types.isTypeVariable( TypeToken.of( Foo.class.getDeclaredMethod("foo", Object.class).getGenericParameterTypes()[0]))) .isTrue(); }
@Test public void isTypeVariable_notGeneric() { assertThat(Types.isTypeVariable(TypeToken.of(Integer.class))).isFalse(); assertThat(Types.isTypeVariable(TypeToken.of(String.class))).isFalse(); assertThat(Types.isTypeVariable(TypeToken.of(Object.class))).isFalse(); assertThat(Types.isTypeVariable(TypeToken.of(String[].class))).isFalse(); assertThat(Types.isTypeVariable(TypeToken.of(Collection.class))).isFalse(); }
@Test public void isTypeVariable_parameterized() { class Foo extends ArrayList<String> {} assertThat(Types.isTypeVariable(TypeToken.of(Foo.class.getGenericSuperclass()))).isFalse(); }