Interface TempDirectory.TempDirContext

    • Method Detail

      • getElement

        AnnotatedElement getElement()
        Get the AnnotatedElement associated with this context.

        The annotated element will be the corresponding Field or Parameter on which @TempDir is declared.

        Favor this method over more specific methods whenever the AnnotatedElement API suits the task at hand — for example, when looking up annotations regardless of concrete element type.

        Returns:
        the AnnotatedElement; never null
        See Also:
        getField(), getParameterContext()
      • findAnnotation

        <A extends AnnotationOptional<A> findAnnotation​(Class<A> annotationType)
        Find the first annotation of annotationType that is either present or meta-present on the Field or Parameter associated with this context.

        WARNING

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

        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
        See Also:
        isAnnotated(Class), findRepeatableAnnotations(Class)
      • findRepeatableAnnotations

        <A extends AnnotationList<A> findRepeatableAnnotations​(Class<A> annotationType)
        Find all repeatable annotations of annotationType that are either present or meta-present on the Field or Parameter associated with this context.

        WARNING

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

        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
        See Also:
        isAnnotated(Class), findAnnotation(Class), Repeatable