Class ThrowsTypeTarget

  • All Implemented Interfaces:
    AnnotationTarget

    public class ThrowsTypeTarget
    extends PositionBasedTypeTarget
    Represents a target of type annotation which occurs in the throws clause of an enclosing method. This class conveys the enclosing method and the zero-based position of the throwable type. The corresponding type reference is also included.

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

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

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

    Since:
    2.0
    • Constructor Detail

      • ThrowsTypeTarget

        ThrowsTypeTarget​(MethodInfo enclosingTarget,
                         int position)
      • ThrowsTypeTarget

        ThrowsTypeTarget​(AnnotationTarget enclosingTarget,
                         Type target,
                         int position)
    • 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
      • asThrows

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