Interface GenericSignature

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.function.Function<java.lang.String,​Type> NO_SUBSTITUTION  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      static void forType​(Type type, java.util.function.Function<java.lang.String,​Type> typeVariableSubstitution, java.lang.StringBuilder result)
      Appends a generic signature of a single type to given StringBuilder.
      static void forTypeParameters​(java.util.List<TypeVariable> typeParameters, java.util.function.Function<java.lang.String,​Type> typeVariableSubstitution, java.lang.StringBuilder result)
      Appends a generic signature of a type parameter list, including the < at the beginning and > at the end, to given StringBuilder.
      default java.lang.String genericSignature()
      Returns a generic signature of this declaration, possibly without any generic-related information.
      java.lang.String genericSignature​(java.util.function.Function<java.lang.String,​Type> typeVariableSubstitution)
      Returns a generic signature of this declaration, possibly without any generic-related information.
      default java.lang.String genericSignatureIfRequired()
      Returns a generic signature of this declaration if required.
      default java.lang.String genericSignatureIfRequired​(java.util.function.Function<java.lang.String,​Type> typeVariableSubstitution)
      Returns a generic signature of this declaration if required.
      boolean requiresGenericSignature()
      Returns whether this declaration must have a generic signature.
    • Field Detail

      • NO_SUBSTITUTION

        static final java.util.function.Function<java.lang.String,​Type> NO_SUBSTITUTION
    • Method Detail

      • requiresGenericSignature

        boolean requiresGenericSignature()
        Returns whether this declaration must have a generic signature. That is, whether the Java compiler when compiling this declaration had to emit the Signature bytecode attribute.
        Returns:
        whether this declaration must have a generic signature
      • genericSignature

        default java.lang.String genericSignature()
        Returns a generic signature of this declaration, possibly without any generic-related information. That is, produces a correct generic signature even if this declaration is not generic and does not use any type variables.

        Note that the return value does not come directly from bytecode. Jandex does not store the signature strings. Instead, the return value is reconstructed from the Jandex object model.

        Returns:
        a generic signature of this declaration, never null
      • genericSignature

        java.lang.String genericSignature​(java.util.function.Function<java.lang.String,​Type> typeVariableSubstitution)
        Returns a generic signature of this declaration, possibly without any generic-related information. That is, produces a correct generic signature even if this declaration is not generic and does not use any type variables.

        Signatures of type variables are substituted for signatures of types provided by the substitution function typeVariableSubstitution. If the substitution function returns null for some type variable identifier, or if it returns the type variable itself, no substitution happens and the type variable signature is used unmodified.

        Note that the return value does not come directly from bytecode. Jandex does not store the signature strings. Instead, the return value is reconstructed from the Jandex object model.

        Parameters:
        typeVariableSubstitution - a substitution function from type variable identifiers to types
        Returns:
        a generic signature of this declaration with type variables substituted, never null
      • genericSignatureIfRequired

        default java.lang.String genericSignatureIfRequired()
        Returns a generic signature of this declaration if required.
        Returns:
        a generic signature of this declaration, or null if this declaration doesn't have to have one
      • genericSignatureIfRequired

        default java.lang.String genericSignatureIfRequired​(java.util.function.Function<java.lang.String,​Type> typeVariableSubstitution)
        Returns a generic signature of this declaration if required. Type variable signatures are substituted.
        Parameters:
        typeVariableSubstitution - a substitution function from type variable identifiers to types
        Returns:
        a generic signature of this declaration with type variables substituted, or null if this declaration does not have to have one
      • forTypeParameters

        static void forTypeParameters​(java.util.List<TypeVariable> typeParameters,
                                      java.util.function.Function<java.lang.String,​Type> typeVariableSubstitution,
                                      java.lang.StringBuilder result)
        Appends a generic signature of a type parameter list, including the < at the beginning and > at the end, to given StringBuilder.

        Signatures of type variables are substituted for signatures of types provided by the substitution function typeVariableSubstitution. If the substitution function returns null for some type variable identifier, or if it returns the type variable itself, no substitution happens and the type variable signature is used unmodified.

        Parameters:
        typeParameters - a list of type parameters whose generic signature is appended to result
        typeVariableSubstitution - a substitution function from type variable identifiers to types
        result - the StringBuilder to which the generic signature is appended
      • forType

        static void forType​(Type type,
                            java.util.function.Function<java.lang.String,​Type> typeVariableSubstitution,
                            java.lang.StringBuilder result)
        Appends a generic signature of a single type to given StringBuilder.

        Signatures of type variables are substituted for signatures of types provided by the substitution function typeVariableSubstitution. If the substitution function returns null for some type variable identifier, or if it returns the type variable itself, no substitution happens and the type variable signature is used unmodified.

        Parameters:
        type - a type parameters whose generic signature is appended to result
        typeVariableSubstitution - a substitution function from type variable identifiers to types
        result - the StringBuilder to which the generic signature is appended