Class ClassExtendsTypeTarget

  • All Implemented Interfaces:
    AnnotationTarget

    public class ClassExtendsTypeTarget
    extends PositionBasedTypeTarget
    Represents a target of type annotation 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 be represented as a ClassExtendsTypeTarget with an enclosing target of the ClassInfo of Foo, and position() would be 0.
    Since:
    2.0
    • Constructor Detail

      • ClassExtendsTypeTarget

        ClassExtendsTypeTarget​(ClassInfo enclosingTarget,
                               int position)
      • 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