Class RecordComponentInfo

    • Constructor Detail

      • RecordComponentInfo

        RecordComponentInfo()
      • RecordComponentInfo

        RecordComponentInfo​(ClassInfo clazz,
                            byte[] name,
                            Type type)
    • 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 component
        name - the name of this record component
        type - 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:
        hasAnnotation in interface AnnotationTarget
        Parameters:
        name - name of the annotation type to look for, must not be null
        Returns:
        true if the annotation is present, false otherwise
        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. The target() 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:
        annotation in interface AnnotationTarget
        Parameters:
        name - name of the annotation type to look for, must not be null
        Returns:
        the annotation instance, or null if 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. The target() method of the returned annotation instances may be used to determine the exact location of the respective annotation instance.
        Specified by:
        annotations in interface AnnotationTarget
        Parameters:
        name - name of the annotation type, must not be null
        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. The target() 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:
        annotationsWithRepeatable in interface AnnotationTarget
        Parameters:
        name - name of the annotation type, must not be null
        index - index used to obtain the annotation type, must not be null
        Returns:
        immutable list of annotation instances, never null
        Throws:
        java.lang.IllegalArgumentException - if the index is null, if the index does not contain the annotation type or if name does 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. The target() method of the returned annotation instances may be used to determine the exact location of the respective annotation instance.
        Specified by:
        annotations in interface AnnotationTarget
        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:
        hasDeclaredAnnotation in interface AnnotationTarget
        Parameters:
        name - name of the annotation type to look for, must not be null
        Returns:
        true if the annotation is present, false otherwise
        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:
        declaredAnnotation in interface AnnotationTarget
        Parameters:
        name - name of the annotation type to look for, must not be null
        Returns:
        the annotation instance, or null if 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:
        declaredAnnotationsWithRepeatable in interface AnnotationTarget
        Parameters:
        name - name of the annotation type, must not be null
        index - index used to obtain the annotation type, must not be null
        Returns:
        immutable list of annotation instances, never null
        Throws:
        java.lang.IllegalArgumentException - if the index is null, if the index does not contain the annotation type or if name does 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:
        declaredAnnotations in interface AnnotationTarget
        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 the Signature bytecode attribute.
        Specified by:
        requiresGenericSignature in interface GenericSignature
        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 returns null for 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:
        genericSignature in interface GenericSignature
        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 returns null for 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:
        descriptor in interface Descriptor
        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:
        toString in class java.lang.Object
        Returns:
        a string representation of this record component
      • asClass

        public final ClassInfo asClass()
        Description copied from interface: AnnotationTarget
        Casts and returns this target as a ClassInfo if it is of kind CLASS
        Specified by:
        asClass in interface AnnotationTarget
        Returns:
        this instance cast to a class
      • asField

        public final FieldInfo asField()
        Description copied from interface: AnnotationTarget
        Casts and returns this target as a FieldInfo if it is of kind FIELD
        Specified by:
        asField in interface AnnotationTarget
        Returns:
        this instance cast to a field
      • asMethod

        public final MethodInfo asMethod()
        Description copied from interface: AnnotationTarget
        Casts and returns this target as a MethodInfo if it is of kind METHOD
        Specified by:
        asMethod in interface AnnotationTarget
        Returns:
        this instance cast to a method
      • asType

        public final TypeTarget asType()
        Description copied from interface: AnnotationTarget
        Casts and returns this target as a TypeTarget if it is of kind TYPE
        Specified by:
        asType in interface AnnotationTarget
        Returns:
        this instance cast to a type target
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • setType

        void setType​(Type type)
      • setClassInfo

        void setClassInfo​(ClassInfo clazz)