TypeHelper { static String toTypeDescription(ParsedType parsedType) { boolean aliasedType = TYPE_DESCRIPTION_ALIASES.containsKey(parsedType.className); String type; if(aliasedType) { type = TYPE_DESCRIPTION_ALIASES.get(parsedType.className); } else { boolean primitive = parsedType.className.startsWith("java.lang"); type = parsedType.className.substring(parsedType.className.lastIndexOf('.') + 1); if (primitive) { type = type.toLowerCase(); } if ("DateTime".equals(type) || "DateMidnight".equals(type)) { type = "Date"; } } if(parsedType.parameters.isEmpty()) { return type; } else { String parametersTypeDescriptions = FluentIterable.from(parsedType.parameters) .transform(new Function<ParsedType, String>() { @Override public String apply(ParsedType param) { return toTypeDescription(param); } }).join(Joiner.on(", ")); if(aliasedType) { return String.format("%s[%s]", type, parametersTypeDescriptions); } else { return String.format("%s<%s>", type, parametersTypeDescriptions); } } }  static OptionalMatchingType optionalMatchingTypeOf(String type);  }
@Test public void should_produce_type_description() throws Exception { assertThat(TypeHelper.toTypeDescription(this.stringedType)).isEqualTo(this.expectedTypeDescription); }