Interface GenericSignature
- All Known Implementing Classes:
ClassInfo
,FieldInfo
,MethodInfo
,RecordComponentInfo
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Appends a generic signature of a single type to givenStringBuilder
.static void
forTypeParameters
(List<TypeVariable> typeParameters, Function<String, Type> typeVariableSubstitution, StringBuilder result) Appends a generic signature of a type parameter list, including the<
at the beginning and>
at the end, to givenStringBuilder
.default String
Returns a generic signature of this declaration, possibly without any generic-related information.genericSignature
(Function<String, Type> typeVariableSubstitution) Returns a generic signature of this declaration, possibly without any generic-related information.default String
Returns a generic signature of this declaration if required.default String
genericSignatureIfRequired
(Function<String, Type> typeVariableSubstitution) Returns a generic signature of this declaration if required.boolean
Returns whether this declaration must have a generic signature.
-
Field Details
-
NO_SUBSTITUTION
-
-
Method Details
-
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 theSignature
bytecode attribute.- Returns:
- whether this declaration must have a generic signature
-
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
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 returnsnull
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
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
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(List<TypeVariable> typeParameters, Function<String, Type> typeVariableSubstitution, StringBuilder result) Appends a generic signature of a type parameter list, including the<
at the beginning and>
at the end, to givenStringBuilder
.Signatures of type variables are substituted for signatures of types provided by the substitution function
typeVariableSubstitution
. If the substitution function returnsnull
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 toresult
typeVariableSubstitution
- a substitution function from type variable identifiers to typesresult
- theStringBuilder
to which the generic signature is appended
-
forType
static void forType(Type type, Function<String, Type> typeVariableSubstitution, StringBuilder result) Appends a generic signature of a single type to givenStringBuilder
.Signatures of type variables are substituted for signatures of types provided by the substitution function
typeVariableSubstitution
. If the substitution function returnsnull
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 toresult
typeVariableSubstitution
- a substitution function from type variable identifiers to typesresult
- theStringBuilder
to which the generic signature is appended
-