Class ClassExtendsTypeTarget

  • All Implemented Interfaces:
    AnnotationTarget

    public class ClassExtendsTypeTarget
    extends PositionBasedTypeTarget
    Represents a type annotation target which occurs in the extends or implements clause of an enclosing class. This class conveys the enclosing class definition, as well as a position to indicate the interface or superclass this target applies to. Since type targets can appear at any depth of the type tree at this location, the corresponding type reference is also included.

    The special position 65535 is used to indicate the type usage is on the super type in the extends clause. All other numbers denote the zero-based offset in the interface list of the implements clause.

    Consider the following example involving a type target using the "Bar" annotation:

     class Foo<T> implements List<@Bar T> {}
     
    This example would return a position of 1 (marking the first interface), an enclosing target of the ClassInfo representing "Foo", and a target type of the type variable "T".
    Since:
    2.0
    Author:
    Jason T. Greene
    • Constructor Detail

      • ClassExtendsTypeTarget

        public ClassExtendsTypeTarget​(AnnotationTarget enclosingTarget,
                                      Type target,
                                      int position)
    • Method Detail

      • usage

        public final TypeTarget.Usage usage()
        Description copied from class: TypeTarget
        Returns the kind of usage of this type target. This allows a caller to use a switch statement as opposed to getClass() comparisons.
        Specified by:
        usage in class TypeTarget
        Returns:
        the kind of usage of this type target
      • asClassExtends

        public ClassExtendsTypeTarget asClassExtends()
        Description copied from class: TypeTarget
        Casts and returns this type target as a ClassExtendsTypeTarget. If this type target is not a ClassExtendsTypeTarget, then an exception will be thrown.
        Overrides:
        asClassExtends in class TypeTarget
        Returns:
        an instance of ClassExtendsTypeTarget