Class TypeParameterBoundTypeTarget

All Implemented Interfaces:
AnnotationTarget

public class TypeParameterBoundTypeTarget extends TypeParameterTypeTarget
Represents a target of type annotation which occurs within a bound of type parameter. This class conveys the zero-based position of the type parameter, the zero-based position of the bound, and finally, 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 <T extends Number & @Bar Serializable> void foo(List<T> l) { ... }
 

This example would be represented as a TypeParameterBoundTypeTarget with an enclosing target of the MethodInfo of foo, position() would be 0 and boundPosition() would be 1.

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

    • boundPosition

      public final int boundPosition()
      Returns the index of the bound this type annotation is within.
      Returns:
      the index of the bound this type annotation is within
    • 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.
      Overrides:
      usage in class TypeParameterTypeTarget
      Returns:
      the kind of usage of this type target
    • asTypeParameterBound

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