ClassName implements TypeName, Comparable<ClassName> { public static ClassName bestGuessFromString(String classNameString) { checkNotNull(classNameString); List<String> parts = Splitter.on('.').splitToList(classNameString); int firstClassPartIndex = -1; for (int i = 0; i < parts.size(); i++) { String part = parts.get(i); checkArgument(SourceVersion.isIdentifier(part)); char firstChar = part.charAt(0); if (Ascii.isLowerCase(firstChar)) { if (firstClassPartIndex >= 0) { throw new IllegalArgumentException("couldn't make a guess for " + classNameString); } } else if (Ascii.isUpperCase(firstChar)) { if (firstClassPartIndex < 0) { firstClassPartIndex = i; } } else { throw new IllegalArgumentException("couldn't make a guess for " + classNameString); } } int lastIndex = parts.size() - 1; return new ClassName( Joiner.on('.').join(parts.subList(0, firstClassPartIndex)), firstClassPartIndex == lastIndex ? ImmutableList.<String>of() : ImmutableList.copyOf(parts.subList(firstClassPartIndex, lastIndex)), parts.get(lastIndex)); } private  ClassName(String packageName, ImmutableList<String> enclosingSimpleNames,
      String simpleName); String packageName(); ImmutableList<String> enclosingSimpleNames(); Optional<ClassName> enclosingClassName(); String simpleName(); String canonicalName(); String classFileName(); ClassName topLevelClassName(); ClassName nestedClassNamed(String memberClassName); ClassName peerNamed(String peerClassName); static ClassName fromTypeElement(TypeElement element); static ClassName fromClass(Class<?> clazz); static ClassName bestGuessFromString(String classNameString); static ClassName create(
      String packageName, List<String> enclosingSimpleNames, String simpleName); static ClassName create(String packageName, String simpleName); @Override String toString(); @Override Appendable write(Appendable appendable, Context context); @Override boolean equals(Object obj); @Override int hashCode(); @Override int compareTo(ClassName o); @Override Set<ClassName> referencedClasses();  }
@Test public void bestGuessForString_confusingInput() { try { ClassName.bestGuessFromString("com.test.$"); fail(); } catch (IllegalArgumentException expected) {} try { ClassName.bestGuessFromString("com.test.LooksLikeAClass.pkg"); fail(); } catch (IllegalArgumentException expected) {} try { ClassName.bestGuessFromString("!@#$gibberish%^&*"); fail(); } catch (IllegalArgumentException expected) {} }