ErrorMessages { static String stripCommonTypePrefixes(String type) { type = type.replace(Provides.Type.class.getCanonicalName() + ".", ""); Matcher matcher = COMMON_PACKAGE_PATTERN.matcher(type); StringBuilder result = new StringBuilder(); int index = 0; while (matcher.find()) { result.append(type.subSequence(index, matcher.start(1))); index = matcher.end(1); } result.append(type.subSequence(index, type.length())); return result.toString(); } private  ErrorMessages();   }
@Test public void stripCommonTypePrefixes() { String typeName = "com.google.common.collect.ImmutableList<java.lang.Boolean>"; assertThat(ErrorMessages.stripCommonTypePrefixes(typeName)).isEqualTo("ImmutableList<Boolean>"); }