Class TypeTarget

    • Method Detail

      • setTarget

        void setTarget​(Type target)
      • enclosingTarget

        public AnnotationTarget enclosingTarget()
        Returns the enclosing target that contains the type referred to by the target() method.
        Returns:
        the enclosing target
      • target

        public Type target()
        Returns the type which contains the respective annotation. In some cases this may be null (e.g. in the case of a bridge method, which erases type information so there is no target to map to)
        Returns:
        the type containing the respective annotation
      • usage

        public abstract TypeTarget.Usage usage()
        Returns the kind of usage of this type target. This allows a caller to use a switch statement as opposed to getClass() comparisons.
        Returns:
        the kind of usage of this type target
      • asClassExtends

        public ClassExtendsTypeTarget asClassExtends()
        Casts and returns this type target as a ClassExtendsTypeTarget. If this type target is not a ClassExtendsTypeTarget, then an exception will be thrown.
        Returns:
        an instance of ClassExtendsTypeTarget
        Throws:
        java.lang.IllegalArgumentException - if this is not a ClassExtendsTypeTarget
      • asMethodParameterType

        public MethodParameterTypeTarget asMethodParameterType()
        Casts and returns this type target as a MethodParameterTypeTarget. If this type target is not a MethodParameterTypeTarget, then an exception will be thrown.
        Returns:
        an instance of MethodParameterTypeTarget
        Throws:
        java.lang.IllegalArgumentException - if this is not a MethodParameterTypeTarget
      • asTypeParameter

        public TypeParameterTypeTarget asTypeParameter()
        Casts and returns this type target as a TypeParameterTypeTarget. If this type target is not a TypeParameterTypeTarget, then an exception will be thrown.
        Returns:
        an instance of TypeParameterTypeTarget
        Throws:
        java.lang.IllegalArgumentException - if this is not a TypeParameterTypeTarget
      • asTypeParameterBound

        public TypeParameterBoundTypeTarget asTypeParameterBound()
        Casts and returns this type target as a TypeParameterBoundTypeTarget. If this type target is not a TypeParameterBoundTypeTarget, then an exception will be thrown.
        Returns:
        an instance of TypeParameterBoundTypeTarget
        Throws:
        java.lang.IllegalArgumentException - if this is not a TypeParameterBoundTypeTarget
      • asThrows

        public ThrowsTypeTarget asThrows()
        Casts and returns this type target as a ThrowsTypeTarget. If this type target is not a ThrowsTypeTarget, then an exception will be thrown.
        Returns:
        an instance of ThrowsTypeTarget
        Throws:
        java.lang.IllegalArgumentException - if this is not a TypeParameterBoundTypeTarget
      • 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