Class DefaultParameterContext
- All Implemented Interfaces:
AnnotatedElementContext,ParameterContext
- Since:
- 5.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultParameterContext(Parameter parameter, int index, Optional<Object> target) -
Method Summary
Modifier and TypeMethodDescription<A extends Annotation>
Optional<A> findAnnotation(Class<A> annotationType) Find the first annotation ofannotationTypethat is either present or meta-present on theAnnotatedElementfor this context.<A extends Annotation>
List<A> findRepeatableAnnotations(Class<A> annotationType) Find all repeatable annotations ofannotationTypethat are either present or meta-present on theAnnotatedElementfor this context.intgetIndex()Get the index of theParameterfor this context within the parameter list of theExecutablethat declares the parameter.Get theParameterfor this context.Get the target on which theExecutablethat declares theParameterfor this context will be invoked, if available.booleanisAnnotated(Class<? extends Annotation> annotationType) Determine if an annotation ofannotationTypeis either present or meta-present on theAnnotatedElementfor this context.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.junit.jupiter.api.extension.ParameterContext
getAnnotatedElement, getDeclaringExecutable
-
Field Details
-
parameter
-
index
private final int index -
target
-
-
Constructor Details
-
DefaultParameterContext
-
-
Method Details
-
getParameter
Description copied from interface:ParameterContextGet theParameterfor this context.WARNING
When searching for annotations on the parameter in this context, favor
ParameterContext.isAnnotated(Class),ParameterContext.findAnnotation(Class), andParameterContext.findRepeatableAnnotations(Class)over methods in theParameterAPI due to a bug injavacon JDK versions prior to JDK 9.- Specified by:
getParameterin interfaceParameterContext- Returns:
- the parameter; never
null - See Also:
-
getIndex
public int getIndex()Description copied from interface:ParameterContextGet the index of theParameterfor this context within the parameter list of theExecutablethat declares the parameter.- Specified by:
getIndexin interfaceParameterContext- Returns:
- the index of the parameter
- See Also:
-
getTarget
Description copied from interface:ParameterContextGet the target on which theExecutablethat declares theParameterfor this context will be invoked, if available.- Specified by:
getTargetin interfaceParameterContext- Returns:
- an
Optionalcontaining the target on which theExecutablewill be invoked; nevernullbut will be empty if theExecutableis a constructor or astaticmethod.
-
isAnnotated
Description copied from interface:ParameterContextDetermine if an annotation ofannotationTypeis either present or meta-present on theAnnotatedElementfor this context.WARNING
Favor the use of this method over directly invoking
AnnotatedElement.isAnnotationPresent(Class)due to a bug injavacon JDK versions prior to JDK 9.- Specified by:
isAnnotatedin interfaceAnnotatedElementContext- Specified by:
isAnnotatedin interfaceParameterContext- Parameters:
annotationType- the annotation type to search for; nevernull- Returns:
trueif the annotation is present or meta-present- See Also:
-
findAnnotation
Description copied from interface:ParameterContextFind the first annotation ofannotationTypethat is either present or meta-present on theAnnotatedElementfor this context.WARNING
Favor the use of this method over directly invoking annotation lookup methods in the
AnnotatedElementAPI due to a bug injavacon JDK versions prior to JDK 9.- Specified by:
findAnnotationin interfaceAnnotatedElementContext- Specified by:
findAnnotationin interfaceParameterContext- Type Parameters:
A- the annotation type- Parameters:
annotationType- the annotation type to search for; nevernull- Returns:
- an
Optionalcontaining the annotation; nevernullbut potentially empty - See Also:
-
findRepeatableAnnotations
Description copied from interface:ParameterContextFind all repeatable annotations ofannotationTypethat are either present or meta-present on theAnnotatedElementfor this context.WARNING
Favor the use of this method over directly invoking annotation lookup methods in the
AnnotatedElementAPI due to a bug injavacon JDK versions prior to JDK 9.- Specified by:
findRepeatableAnnotationsin interfaceAnnotatedElementContext- Specified by:
findRepeatableAnnotationsin interfaceParameterContext- 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
nullnor mutable, but potentially empty - See Also:
-
toString
-