static StringBuilder append(StringBuilder builder, TypeMirror mirror) {
    TypeKind kind = mirror.getKind();
    if (kind.isPrimitive()) {
      List<? extends AnnotationMirror> annotations = mirror.getAnnotationMirrors();
      if (!annotations.isEmpty()) {
        append(builder, annotations);
        builder.append(' ');
      }
      builder.append(kind.name().toLowerCase());
      return builder;
    }

    if (kind == TypeKind.DECLARED) {
      DeclaredType declared = (DeclaredType) mirror;
      TypeElement element = (TypeElement) declared.asElement();
      List<? extends AnnotationMirror> annotations = declared.getAnnotationMirrors();
      if (!annotations.isEmpty()) {
        String qualifiedName = element.getQualifiedName().toString();
        int qualifiedDotIndex = qualifiedName.lastIndexOf('.');

        if (qualifiedDotIndex > 0) {
          // special syntax for qualified name and type annotations:
          // org.package.name.@Annotation @Another SimpleName
          builder.append(qualifiedName, 0, qualifiedDotIndex + 1);
        }
        append(builder, annotations);
        // finishing with the type name itself
        builder.append(' ');
        if (qualifiedDotIndex > 0) {
          builder.append(qualifiedName, qualifiedDotIndex + 1, qualifiedName.length());
        } else {
          // this can be the case for unnamed package (right?)
          builder.append(qualifiedName);
        }
      } else {
        builder.append(element.getQualifiedName());
      }

      List<? extends TypeMirror> arguments = declared.getTypeArguments();
      if (!arguments.isEmpty()) {
        builder.append('<');
        int i = 0;
        for (TypeMirror a : arguments) {
          if (i++ > 0) builder.append(", ");
          // recursive call
          append(builder, a);
        }
        builder.append('>');
      }
      return builder;
    }

    return builder.append(mirror);
  }
overridable stringify.
@param input the input
@param context the context
@return the string
generator/src/org/immutables/generator/TypeHierarchyCollector.java