code: public static QualifiedName of(TypeElement type) {
      switch (type.getNestingKind()) {
        case TOP_LEVEL:
          PackageElement pkg = (PackageElement) type.getEnclosingElement();
          return QualifiedName.of(pkg.getQualifiedName().toString(), type.getSimpleName().toString());
  
        case MEMBER:
          List<String> reversedNames = new ArrayList<String>();
          reversedNames.add(type.getSimpleName().toString());
          Element parent = type.getEnclosingElement();
          while (parent.getKind() != ElementKind.PACKAGE) {
            reversedNames.add(parent.getSimpleName().toString());
            parent = parent.getEnclosingElement();
          }
          return new QualifiedName(
              ((PackageElement) parent).getQualifiedName().toString(),
              ImmutableList.copyOf(Lists.reverse(reversedNames)));
  
        default:
          throw new IllegalArgumentException("Cannot determine qualified name of " + type);
      }
    }
docs: Returns a {@link QualifiedName} for {@code type}.