Types { public static TypeToken<?> getTypeParameter(TypeToken<?> type, int index) { Preconditions.checkArgument( type.getType() instanceof ParameterizedType, "type is not parameterized"); Type[] typeArgs = ((ParameterizedType) type.getType()).getActualTypeArguments(); if (typeArgs.length <= index) { throw new IndexOutOfBoundsException( String.format("type '%s' has %d <= %d type arguments", type, typeArgs.length, index)); } return type.resolveType(typeArgs[index]); }  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 getTypeParameter() { assertThat(Types.getTypeParameter(STRING_COLLECTION, 0)).isEqualTo(STRING); }
@Test public void getTypeParameter_notParameterized() { try { Types.getTypeParameter(STRING, 0); fail("expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
@Test public void getTypeParameter_notEnoughParameters() { try { Types.getTypeParameter(STRING_COLLECTION, 1); fail("expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException expected) { } }