Class RecordComponentInfo
- java.lang.Object
-
- org.jboss.jandex.RecordComponentInfo
-
- All Implemented Interfaces:
AnnotationTarget,Declaration,Descriptor,GenericSignature
public final class RecordComponentInfo extends java.lang.Object implements Declaration, Descriptor, GenericSignature
Represents an individual Java record component that was annotated.Thread-Safety
This class is immutable and can be shared between threads without safe publication.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jboss.jandex.AnnotationTarget
AnnotationTarget.Kind
-
-
Field Summary
Fields Modifier and Type Field Description private ClassInfoclazzprivate RecordComponentInternalinternal-
Fields inherited from interface org.jboss.jandex.Descriptor
NO_SUBSTITUTION
-
Fields inherited from interface org.jboss.jandex.GenericSignature
NO_SUBSTITUTION
-
-
Constructor Summary
Constructors Constructor Description RecordComponentInfo()RecordComponentInfo(ClassInfo clazz, byte[] name, Type type)RecordComponentInfo(ClassInfo clazz, RecordComponentInternal internal)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MethodInfoaccessor()Returns the accessor method corresponding to this record component.AnnotationInstanceannotation(DotName name)Returns the annotation instance with given name declared on this record component or any type within its signature.java.util.List<AnnotationInstance>annotations()Returns the annotation instances declared on this record component or any type within its signature.java.util.List<AnnotationInstance>annotations(DotName name)Returns the annotation instances with given name declared on this record component or any type within its signature.java.util.List<AnnotationInstance>annotationsWithRepeatable(DotName name, IndexView index)Returns the annotation instances with given name declared on this record component or any type within its signature.ClassInfoasClass()Casts and returns this target as aClassInfoif it is of kindCLASSFieldInfoasField()Casts and returns this target as aFieldInfoif it is of kindFIELDMethodInfoasMethod()Casts and returns this target as aMethodInfoif it is of kindMETHODMethodParameterInfoasMethodParameter()Casts and returns this target as aMethodParameterInfoif it is of kindMETHOD_PARAMETERRecordComponentInfoasRecordComponent()Casts and returns this target as aRecordComponentInfoif it is of kindRECORD_COMPONENTTypeTargetasType()Casts and returns this target as aTypeTargetif it is of kindTYPEstatic RecordComponentInfocreate(ClassInfo clazz, java.lang.String name, Type type)Constructs a new mock record component infoAnnotationInstancedeclaredAnnotation(DotName name)Returns the annotation instance with given name declared on this record component.java.util.List<AnnotationInstance>declaredAnnotations()Returns the annotation instances declared on this record component.java.util.List<AnnotationInstance>declaredAnnotationsWithRepeatable(DotName name, IndexView index)Returns the annotation instances with given name declared on this record component.ClassInfodeclaringClass()Returns the (record) class declaring this record component.java.lang.Stringdescriptor(java.util.function.Function<java.lang.String,Type> typeVariableSubstitution)Returns a bytecode descriptor of this record component.booleanequals(java.lang.Object o)FieldInfofield()Returns the component field corresponding to this record component.java.lang.StringgenericSignature(java.util.function.Function<java.lang.String,Type> typeVariableSubstitution)Returns a generic signature of this record component, possibly without any generic-related information.booleanhasAnnotation(DotName name)Returns whether an annotation instance with given name is declared on this record component or any type within its signature.booleanhasDeclaredAnnotation(DotName name)Returns whether an annotation instance with given name is declared on this record component.inthashCode()AnnotationTarget.Kindkind()Returns the kind of object this target represents.java.lang.Stringname()Returns the name of this record component.(package private) RecordComponentInternalrecordComponentInternal()booleanrequiresGenericSignature()Returns whether this record component must have a generic signature.(package private) voidsetAnnotations(java.util.List<AnnotationInstance> annotations)(package private) voidsetClassInfo(ClassInfo clazz)(package private) voidsetRecordComponentInternal(RecordComponentInternal internal)(package private) voidsetType(Type type)java.lang.StringtoString()Returns a string representation describing this record component.Typetype()Returns the type of this record component.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jboss.jandex.AnnotationTarget
annotation, annotation, annotations, annotations, annotationsWithRepeatable, annotationsWithRepeatable, declaredAnnotation, declaredAnnotation, declaredAnnotationsWithRepeatable, declaredAnnotationsWithRepeatable, hasAnnotation, hasAnnotation, hasDeclaredAnnotation, hasDeclaredAnnotation
-
Methods inherited from interface org.jboss.jandex.Declaration
asDeclaration, isDeclaration
-
Methods inherited from interface org.jboss.jandex.Descriptor
descriptor
-
Methods inherited from interface org.jboss.jandex.GenericSignature
genericSignature, genericSignatureIfRequired, genericSignatureIfRequired
-
-
-
-
Field Detail
-
clazz
private ClassInfo clazz
-
internal
private RecordComponentInternal internal
-
-
Constructor Detail
-
RecordComponentInfo
RecordComponentInfo()
-
RecordComponentInfo
RecordComponentInfo(ClassInfo clazz, RecordComponentInternal internal)
-
-
Method Detail
-
create
public static RecordComponentInfo create(ClassInfo clazz, java.lang.String name, Type type)
Constructs a new mock record component info- Parameters:
clazz- the (record) class declaring this record componentname- the name of this record componenttype- the type of this record component- Returns:
- the new mock record component info
-
declaringClass
public final ClassInfo declaringClass()
Returns the (record) class declaring this record component.- Returns:
- the (record) class declaring this record component
-
field
public final FieldInfo field()
Returns the component field corresponding to this record component.- Returns:
- the component field
-
accessor
public final MethodInfo accessor()
Returns the accessor method corresponding to this record component.- Returns:
- the accessor method
-
name
public final java.lang.String name()
Returns the name of this record component.- Returns:
- the name of this record component
-
type
public Type type()
Returns the type of this record component.- Returns:
- the type of this record component
-
hasAnnotation
public final boolean hasAnnotation(DotName name)
Returns whether an annotation instance with given name is declared on this record component or any type within its signature.- Specified by:
hasAnnotationin interfaceAnnotationTarget- Parameters:
name- name of the annotation type to look for, must not benull- Returns:
trueif the annotation is present,falseotherwise- See Also:
annotation(DotName)
-
annotation
public final AnnotationInstance annotation(DotName name)
Returns the annotation instance with given name declared on this record component or any type within its signature. Thetarget()method of the returned annotation instance may be used to determine the exact location of the annotation instance.In case an annotation with given name occurs more than once, the result of this method is not deterministic. For such situations,
annotations(DotName)is preferable.- Specified by:
annotationin interfaceAnnotationTarget- Parameters:
name- name of the annotation type to look for, must not benull- Returns:
- the annotation instance, or
nullif not found - See Also:
annotations(DotName)
-
annotations
public final java.util.List<AnnotationInstance> annotations(DotName name)
Returns the annotation instances with given name declared on this record component or any type within its signature. Thetarget()method of the returned annotation instances may be used to determine the exact location of the respective annotation instance.- Specified by:
annotationsin interfaceAnnotationTarget- Parameters:
name- name of the annotation type, must not benull- Returns:
- immutable list of annotation instances, never
null - Since:
- 3.0
- See Also:
annotationsWithRepeatable(DotName, IndexView),annotations()
-
annotationsWithRepeatable
public final java.util.List<AnnotationInstance> annotationsWithRepeatable(DotName name, IndexView index)
Returns the annotation instances with given name declared on this record component or any type within its signature. Thetarget()method of the returned annotation instances may be used to determine the exact location of the respective annotation instance.If the specified annotation is repeatable, the result also contains all values from the container annotation instance. In this case, the
AnnotationInstance.target()returns the target of the container annotation instance.- Specified by:
annotationsWithRepeatablein interfaceAnnotationTarget- Parameters:
name- name of the annotation type, must not benullindex- index used to obtain the annotation type, must not benull- Returns:
- immutable list of annotation instances, never
null - Throws:
java.lang.IllegalArgumentException- if the index isnull, if the index does not contain the annotation type or ifnamedoes not identify an annotation type- See Also:
annotations(DotName),annotations()
-
annotations
public final java.util.List<AnnotationInstance> annotations()
Returns the annotation instances declared on this record component or any type within its signature. Thetarget()method of the returned annotation instances may be used to determine the exact location of the respective annotation instance.- Specified by:
annotationsin interfaceAnnotationTarget- Returns:
- immutable list of annotation instances, never
null
-
hasDeclaredAnnotation
public final boolean hasDeclaredAnnotation(DotName name)
Returns whether an annotation instance with given name is declared on this record component.Unlike
hasAnnotation(DotName), this method ignores annotations declared on types within the record component signature.- Specified by:
hasDeclaredAnnotationin interfaceAnnotationTarget- Parameters:
name- name of the annotation type to look for, must not benull- Returns:
trueif the annotation is present,falseotherwise- Since:
- 3.0
- See Also:
hasAnnotation(DotName)
-
declaredAnnotation
public final AnnotationInstance declaredAnnotation(DotName name)
Returns the annotation instance with given name declared on this record component.Unlike
annotation(DotName), this method doesn't return annotations declared on types within the record component signature.- Specified by:
declaredAnnotationin interfaceAnnotationTarget- Parameters:
name- name of the annotation type to look for, must not benull- Returns:
- the annotation instance, or
nullif not found - Since:
- 3.0
- See Also:
annotation(DotName)
-
declaredAnnotationsWithRepeatable
public final java.util.List<AnnotationInstance> declaredAnnotationsWithRepeatable(DotName name, IndexView index)
Returns the annotation instances with given name declared on this record component.If the specified annotation is repeatable, the result also contains all values from the container annotation instance. In this case, the
AnnotationInstance.target()returns the target of the container annotation instance.Unlike
annotationsWithRepeatable(DotName, IndexView), this method doesn't return annotations declared on types within the record component signature.- Specified by:
declaredAnnotationsWithRepeatablein interfaceAnnotationTarget- Parameters:
name- name of the annotation type, must not benullindex- index used to obtain the annotation type, must not benull- Returns:
- immutable list of annotation instances, never
null - Throws:
java.lang.IllegalArgumentException- if the index isnull, if the index does not contain the annotation type or ifnamedoes not identify an annotation type- Since:
- 3.0
- See Also:
annotationsWithRepeatable(DotName, IndexView)
-
declaredAnnotations
public final java.util.List<AnnotationInstance> declaredAnnotations()
Returns the annotation instances declared on this record component.Unlike
annotations(), this method doesn't return annotations declared on types within the record component signature.- Specified by:
declaredAnnotationsin interfaceAnnotationTarget- Returns:
- immutable list of annotation instances, never
null - Since:
- 3.0
- See Also:
annotations()
-
requiresGenericSignature
public boolean requiresGenericSignature()
Returns whether this record component must have a generic signature. That is, whether the Java compiler when compiling this record component had to emit theSignaturebytecode attribute.- Specified by:
requiresGenericSignaturein interfaceGenericSignature- Returns:
- whether this record component must have a generic signature
-
genericSignature
public java.lang.String genericSignature(java.util.function.Function<java.lang.String,Type> typeVariableSubstitution)
Returns a generic signature of this record component, possibly without any generic-related information. That is, produces a correct generic signature even if this record component 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 returnsnullfor some type variable identifier, 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.
- Specified by:
genericSignaturein interfaceGenericSignature- Parameters:
typeVariableSubstitution- a substitution function from type variable identifiers to types- Returns:
- a generic signature of this record component with type variables substituted, never
null
-
descriptor
public java.lang.String descriptor(java.util.function.Function<java.lang.String,Type> typeVariableSubstitution)
Returns a bytecode descriptor of this record component.Descriptors of type variables are substituted for descriptors of types provided by the substitution function
typeVariableSubstitution. If the substitution function returnsnullfor some type variable identifier, or if it returns the type variable itself, no substitution happens and the type variable descriptor is used unmodified.Note that the return value does not come directly from bytecode. Jandex does not store the descriptor strings. Instead, the return value is reconstructed from the Jandex object model.
- Specified by:
descriptorin interfaceDescriptor- Parameters:
typeVariableSubstitution- a substitution function from type variable identifiers to types- Returns:
- the bytecode descriptor of this record component
-
toString
public java.lang.String toString()
Returns a string representation describing this record component. It is similar although not necessarily identical to a Java source code declaration of this record component.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of this record component
-
asClass
public final ClassInfo asClass()
Description copied from interface:AnnotationTargetCasts and returns this target as aClassInfoif it is of kindCLASS- Specified by:
asClassin interfaceAnnotationTarget- Returns:
- this instance cast to a class
-
asField
public final FieldInfo asField()
Description copied from interface:AnnotationTargetCasts and returns this target as aFieldInfoif it is of kindFIELD- Specified by:
asFieldin interfaceAnnotationTarget- Returns:
- this instance cast to a field
-
asMethod
public final MethodInfo asMethod()
Description copied from interface:AnnotationTargetCasts and returns this target as aMethodInfoif it is of kindMETHOD- Specified by:
asMethodin interfaceAnnotationTarget- Returns:
- this instance cast to a method
-
asMethodParameter
public final MethodParameterInfo asMethodParameter()
Description copied from interface:AnnotationTargetCasts and returns this target as aMethodParameterInfoif it is of kindMETHOD_PARAMETER- Specified by:
asMethodParameterin interfaceAnnotationTarget- Returns:
- this instance cast to a method parameter
-
asType
public final TypeTarget asType()
Description copied from interface:AnnotationTargetCasts and returns this target as aTypeTargetif it is of kindTYPE- Specified by:
asTypein interfaceAnnotationTarget- Returns:
- this instance cast to a type target
-
asRecordComponent
public final RecordComponentInfo asRecordComponent()
Description copied from interface:AnnotationTargetCasts and returns this target as aRecordComponentInfoif it is of kindRECORD_COMPONENT- Specified by:
asRecordComponentin interfaceAnnotationTarget- Returns:
- this instance cast to a record component
-
kind
public AnnotationTarget.Kind kind()
Description copied from interface:AnnotationTargetReturns the kind of object this target represents.- Specified by:
kindin interfaceAnnotationTarget- Returns:
- the target kind.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
setType
void setType(Type type)
-
setAnnotations
void setAnnotations(java.util.List<AnnotationInstance> annotations)
-
recordComponentInternal
RecordComponentInternal recordComponentInternal()
-
setRecordComponentInternal
void setRecordComponentInternal(RecordComponentInternal internal)
-
setClassInfo
void setClassInfo(ClassInfo clazz)
-
-