Class MethodParameterTypeTarget

  • All Implemented Interfaces:
    AnnotationTarget

    public class MethodParameterTypeTarget
    extends PositionBasedTypeTarget
    Represents a type annotation target which occurs within a method parameter type. This class conveys the enclosing method and the zero-based position of the parameter. 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 void foo(List<@Bar T> { ... }
     

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

    Since:
    2.0
    • Constructor Detail

      • MethodParameterTypeTarget

        MethodParameterTypeTarget​(MethodInfo enclosingTarget,
                                  int position)
      • MethodParameterTypeTarget

        MethodParameterTypeTarget​(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
      • asMethodParameterType

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