Types { public static String getSimpleName(TypeToken<?> type, ApiSerializationConfig config) { if (type == null) { return null; } TypeToken<?> itemType = getArrayItemType(type); if (itemType != null) { return getSimpleName(itemType, config) + "Collection"; } else if (type.getType() instanceof ParameterizedType) { Class<?> clazz = type.getRawType(); StringBuilder builder = new StringBuilder(); builder.append(clazz.getSimpleName()); for (Type typeArg : clazz.getTypeParameters()) { builder.append('_'); builder.append(getSimpleName(type.resolveType(typeArg), config)); } return builder.toString(); } else { Class<? extends Transformer<?, ?>> serializerClass = Iterables.getOnlyElement( Serializers.getSerializerClasses(type, config), null); if (serializerClass != null && ResourceTransformer.class.isAssignableFrom(serializerClass)) { @SuppressWarnings("unchecked") ResourceTransformer<?> resourceSerializer = (ResourceTransformer<?>) Serializers.instantiate(serializerClass, type); ResourceSchema resourceSchema = resourceSerializer.getResourceSchema(); if (resourceSchema != null && resourceSchema.getName() != null) { return resourceSchema.getName(); } } String collectionName = FieldType.fromType(type).getCollectionName(); return collectionName != null ? collectionName : type.getRawType().getSimpleName(); } }  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 getSimpleName_null() { assertThat(Types.getSimpleName(null, apiConfig.getSerializationConfig())).isNull(); }
@Test public void getSimpleName_array() { assertThat(getSimpleName(String[].class)).isEqualTo("StringCollection"); }
@Test public void getSimpleName_basic() { assertThat(getSimpleName(String.class)).isEqualTo("String"); }
@Test public void getSimpleName_withSerializer() { assertThat(getSimpleName(Integer.class)).isEqualTo("Integer"); }
@Test public void getSimpleName_withResourceSerializerNameOverride() { assertThat(getSimpleName(Long.class)).isEqualTo("Number"); }
@Test public void getSimpleName_withResourceSerializerNoNameOverride() { assertThat(getSimpleName(Float.class)).isEqualTo("Float"); }
@Test public void getSimpleName_parameterized() { class Foo extends Base2<Integer, Base<String>> { } ParameterizedType type = (ParameterizedType) Foo.class.getGenericSuperclass(); assertThat(getSimpleName(type)).isEqualTo("Base2_Integer_Base_String"); }