private String getBinaryNameImpl(TypeElement element, String className) {
    Element enclosingElement = element.getEnclosingElement();

    if (enclosingElement instanceof PackageElement) {
      PackageElement pkg = MoreElements.asPackage(enclosingElement);
      if (pkg.isUnnamed()) {
        return className;
      }
      return pkg.getQualifiedName() + "." + className;
    }

    TypeElement typeElement = MoreElements.asType(enclosingElement);
    return getBinaryNameImpl(typeElement, typeElement.getSimpleName() + "$" + className);
  }
Returns the binary name of a reference type. For example, {@code com.google.Foo$Bar}, instead
of {@code com.google.Foo.Bar}.
service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java