Interface ParameterContext

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default <A extends java.lang.annotation.Annotation>
      java.util.Optional<A>
      findAnnotation​(java.lang.Class<A> annotationType)
      Find the first annotation of annotationType that is either present or meta-present on the AnnotatedElement for this context.
      default <A extends java.lang.annotation.Annotation>
      java.util.List<A>
      findRepeatableAnnotations​(java.lang.Class<A> annotationType)
      Find all repeatable annotations of annotationType that are either present or meta-present on the AnnotatedElement for this context.
      default java.lang.reflect.AnnotatedElement getAnnotatedElement()
      Get the AnnotatedElement for this context.
      default java.lang.reflect.Executable getDeclaringExecutable()
      Get the Executable (i.e., the Method or Constructor) that declares the Parameter for this context.
      int getIndex()
      Get the index of the Parameter for this context within the parameter list of the Executable that declares the parameter.
      java.lang.reflect.Parameter getParameter()
      Get the Parameter for this context.
      java.util.Optional<java.lang.Object> getTarget()
      Get the target on which the Executable that declares the Parameter for this context will be invoked, if available.
      default boolean isAnnotated​(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
      Determine if an annotation of annotationType is either present or meta-present on the AnnotatedElement for this context.
    • Method Detail

      • getIndex

        int getIndex()
        Get the index of the Parameter for this context within the parameter list of the Executable that declares the parameter.
        Returns:
        the index of the parameter
        See Also:
        getParameter(), Executable.getParameters()
      • getDeclaringExecutable

        default java.lang.reflect.Executable getDeclaringExecutable()
        Get the Executable (i.e., the Method or Constructor) that declares the Parameter for this context.
        Returns:
        the declaring Executable; never null
        See Also:
        Parameter.getDeclaringExecutable()
      • getTarget

        java.util.Optional<java.lang.Object> getTarget()
        Get the target on which the Executable that declares the Parameter for this context will be invoked, if available.
        Returns:
        an Optional containing the target on which the Executable will be invoked; never null but will be empty if the Executable is a constructor or a static method.
      • isAnnotated

        @API(status=STABLE,
             since="5.10")
        default boolean isAnnotated​(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
        Determine if an annotation of annotationType is either present or meta-present on the AnnotatedElement for this context.

        WARNING

        Favor the use of this method over directly invoking AnnotatedElement.isAnnotationPresent(Class) due to a bug in javac on JDK versions prior to JDK 9.

        Specified by:
        isAnnotated in interface AnnotatedElementContext
        Parameters:
        annotationType - the annotation type to search for; never null
        Returns:
        true if the annotation is present or meta-present
        Since:
        5.1.1
        See Also:
        AnnotatedElementContext.findAnnotation(Class), AnnotatedElementContext.findRepeatableAnnotations(Class)
      • findAnnotation

        @API(status=STABLE,
             since="5.10")
        default <A extends java.lang.annotation.Annotation> java.util.Optional<A> findAnnotation​(java.lang.Class<A> annotationType)
        Find the first annotation of annotationType that is either present or meta-present on the AnnotatedElement for this context.

        WARNING

        Favor the use of this method over directly invoking annotation lookup methods in the AnnotatedElement API due to a bug in javac on JDK versions prior to JDK 9.

        Specified by:
        findAnnotation in interface AnnotatedElementContext
        Type Parameters:
        A - the annotation type
        Parameters:
        annotationType - the annotation type to search for; never null
        Returns:
        an Optional containing the annotation; never null but potentially empty
        Since:
        5.1.1
        See Also:
        AnnotatedElementContext.isAnnotated(Class), AnnotatedElementContext.findRepeatableAnnotations(Class)
      • findRepeatableAnnotations

        @API(status=STABLE,
             since="5.10")
        default <A extends java.lang.annotation.Annotation> java.util.List<A> findRepeatableAnnotations​(java.lang.Class<A> annotationType)
        Find all repeatable annotations of annotationType that are either present or meta-present on the AnnotatedElement for this context.

        WARNING

        Favor the use of this method over directly invoking annotation lookup methods in the AnnotatedElement API due to a bug in javac on JDK versions prior to JDK 9.

        Specified by:
        findRepeatableAnnotations in interface AnnotatedElementContext
        Type Parameters:
        A - the annotation type
        Parameters:
        annotationType - the repeatable annotation type to search for; never null
        Returns:
        the list of all such annotations found; neither null nor mutable, but potentially empty
        Since:
        5.1.1
        See Also:
        AnnotatedElementContext.isAnnotated(Class), AnnotatedElementContext.findAnnotation(Class), Repeatable