Interface TempDirectory.TempDirContext
-
- Enclosing class:
- TempDirectory
public static interface TempDirectory.TempDirContext
TempDirContext
encapsulates the context in which@TempDir
is declared.- See Also:
TempDirectory.ParentDirProvider
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <A extends Annotation>
Optional<A>findAnnotation(Class<A> annotationType)
<A extends Annotation>
List<A>findRepeatableAnnotations(Class<A> annotationType)
Find all repeatable annotations ofannotationType
that are either present or meta-present on theField
orParameter
associated with this context.AnnotatedElement
getElement()
Get theAnnotatedElement
associated with this context.Optional<Field>
getField()
Get theField
associated with this context, if available.Optional<ParameterContext>
getParameterContext()
Get theParameterContext
associated with this context, if available.boolean
isAnnotated(Class<? extends Annotation> annotationType)
-
-
-
Method Detail
-
getElement
AnnotatedElement getElement()
Get theAnnotatedElement
associated with this context.The annotated element will be the corresponding
Field
orParameter
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
; nevernull
- See Also:
getField()
,getParameterContext()
-
getField
Optional<Field> getField()
Get theField
associated with this context, if available.If this method returns an empty
Optional
,getParameterContext()
will return a non-emptyOptional
.- Returns:
- an
Optional
containing the field; nevernull
but potentially empty - See Also:
getElement()
,getParameterContext()
-
getParameterContext
Optional<ParameterContext> getParameterContext()
Get theParameterContext
associated with this context, if available.If this method returns an empty
Optional
,getField()
will return a non-emptyOptional
.- Returns:
- an
Optional
containing theParameterContext
; nevernull
but potentially empty - See Also:
getElement()
,getField()
-
isAnnotated
boolean isAnnotated(Class<? extends Annotation> annotationType)
Determine if an annotation ofannotationType
is either present or meta-present on theField
orParameter
associated with this context.WARNING
Favor the use of this method over directly invoking
AnnotatedElement.isAnnotationPresent(Class)
due to a bug injavac
on JDK versions prior to JDK 9.- Parameters:
annotationType
- the annotation type to search for; nevernull
- Returns:
true
if the annotation is present or meta-present- See Also:
findAnnotation(Class)
,findRepeatableAnnotations(Class)
-
findAnnotation
<A extends Annotation> Optional<A> findAnnotation(Class<A> annotationType)
Find the first annotation ofannotationType
that is either present or meta-present on theField
orParameter
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 injavac
on JDK versions prior to JDK 9.- Type Parameters:
A
- the annotation type- Parameters:
annotationType
- the annotation type to search for; nevernull
- Returns:
- an
Optional
containing the annotation; nevernull
but potentially empty - See Also:
isAnnotated(Class)
,findRepeatableAnnotations(Class)
-
findRepeatableAnnotations
<A extends Annotation> List<A> findRepeatableAnnotations(Class<A> annotationType)
Find all repeatable annotations ofannotationType
that are either present or meta-present on theField
orParameter
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 injavac
on JDK versions prior to JDK 9.- Type Parameters:
A
- the annotation type- Parameters:
annotationType
- the repeatable annotation type to search for; nevernull
- Returns:
- the list of all such annotations found; neither
null
nor mutable, but potentially empty - See Also:
isAnnotated(Class)
,findAnnotation(Class)
,Repeatable
-
-