private void genTypeSignature(TypeMirror type, StringBuilder sb) {
    switch (type.getKind()) {
      case BOOLEAN:
      case BYTE:
      case CHAR:
      case DOUBLE:
      case FLOAT:
      case INT:
      case LONG:
      case SHORT:
      case VOID:
        sb.append(TypeUtil.getBinaryName(type));
        break;
      case ARRAY:
        // ArrayTypeSignature ::= "[" TypSignature.
        sb.append('[');
        genTypeSignature(((ArrayType) type).getComponentType(), sb);
        break;
      case DECLARED:
        String typeName = elementUtil.getBinaryName(TypeUtil.asTypeElement(type));
        if (!TypeUtil.isStubType(typeName)) {
          // ClassTypeSignature ::= "L" {Ident "/"} Ident
          //   OptTypeArguments {"." Ident OptTypeArguments} ";".
          sb.append('L');
          sb.append(typeName.replace('.', '/'));
          genOptTypeArguments(((DeclaredType) type).getTypeArguments(), sb);
          sb.append(';');
        }
        break;
      case TYPEVAR:
        // TypeVariableSignature ::= "T" Ident ";".
        sb.append('T');
        sb.append(ElementUtil.getName(((TypeVariable) type).asElement()));
        sb.append(';');
        break;
      case WILDCARD:
        // TypeArgument ::= (["+" | "-"] FieldTypeSignature) | "*".
        TypeMirror upperBound = ((WildcardType) type).getExtendsBound();
        TypeMirror lowerBound = ((WildcardType) type).getSuperBound();
        if (upperBound != null) {
          sb.append('+');
          genTypeSignature(upperBound, sb);
        } else if (lowerBound != null) {
          sb.append('-');
          genTypeSignature(lowerBound, sb);
        } else {
          sb.append('*');
        }
        break;
      default:
        throw new AssertionError("Unexpected type kind: " + type.getKind());
    }
  }
private void genTypeSignature ( TypeMirror type , StringBuilder sb ) { switch ( type . getKind ( ) ) { case BOOLEAN : case BYTE : case CHAR : case DOUBLE : case FLOAT : case INT : case LONG : case SHORT : case VOID : sb . append ( TypeUtil . getBinaryName ( type ) ) ; break ; case ARRAY : sb . append ( '[' ) ; genTypeSignature ( ( ( ArrayType ) type ) . getComponentType ( ) , sb ) ; break ; case DECLARED : String typeName = elementUtil . getBinaryName ( TypeUtil . asTypeElement ( type ) ) ; if ( ! TypeUtil . isStubType ( typeName ) ) { sb . append ( 'L' ) ; sb . append ( typeName . replace ( '.' , '/' ) ) ; genOptTypeArguments ( ( ( DeclaredType ) type ) . getTypeArguments ( ) , sb ) ; sb . append ( ';' ) ; } break ; case TYPEVAR : sb . append ( 'T' ) ; sb . append ( ElementUtil . getName ( ( ( TypeVariable ) type ) . asElement ( ) ) ) ; sb . append ( ';' ) ; break ; case WILDCARD : TypeMirror upperBound = ( ( WildcardType ) type ) . getExtendsBound ( ) ; TypeMirror lowerBound = ( ( WildcardType ) type ) . getSuperBound ( ) ; if ( upperBound != null ) { sb . append ( '+' ) ; genTypeSignature ( upperBound , sb ) ; } else if ( lowerBound != null ) { sb . append ( '-' ) ; genTypeSignature ( lowerBound , sb ) ; } else { sb . append ( '*' ) ; } break ; default : throw new AssertionError ( "Unexpected type kind: " + type . getKind ( ) ) ; } }
TODO(kstanger): Figure out if this can replace TypeUtil.getSignatureName().