Class TypeParameterTypeTarget

  • All Implemented Interfaces:
    AnnotationTarget
    Direct Known Subclasses:
    TypeParameterBoundTypeTarget

    public class TypeParameterTypeTarget
    extends PositionBasedTypeTarget
    Represents a type annotation target which occurs within a type parameter type. This class conveys the zero-based position of the parameter, and the enclosing method or class where it occurs. Since type targets can appear at any depth of the type tree at this location, the corresponding type reference is also included.

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

     public <@Bar T> void foo(List<T>) { ... }
     

    This example would be represented as a TypeParameterTypeTarget with an enclosing target of foo's MethodInfo, and position() would return 0. The "Bar" annotation would appear on the type variable T when invoking the typeParameters() method on MethodInfo

    Since:
    2.0
    Author:
    Jason T. Greene
    • Method Detail

      • usage

        public 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
      • asTypeParameter

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