- All Superinterfaces:
AnnotatedElementContext
ParameterContext encapsulates the context in which an
Executable will be invoked for a given
Parameter.
A ParameterContext is used to support parameter resolution via
a ParameterResolver.
- Since:
- 5.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault <A extends Annotation>
Optional<A> findAnnotation(Class<A> annotationType) Find the first annotation ofannotationTypethat is either present or meta-present on theAnnotatedElementfor this context.default <A extends Annotation>
List<A> findRepeatableAnnotations(Class<A> annotationType) Find all repeatable annotations ofannotationTypethat are either present or meta-present on theAnnotatedElementfor this context.default AnnotatedElementGet theAnnotatedElementfor this context.default ExecutableintgetIndex()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.default booleanisAnnotated(Class<? extends Annotation> annotationType) Determine if an annotation ofannotationTypeis either present or meta-present on theAnnotatedElementfor this context.
-
Method Details
-
getParameter
Parameter getParameter()Get theParameterfor this context.WARNING
When searching for annotations on the parameter in this context, favor
isAnnotated(Class),findAnnotation(Class), andfindRepeatableAnnotations(Class)over methods in theParameterAPI due to a bug injavacon JDK versions prior to JDK 9.- Returns:
- the parameter; never
null - See Also:
-
getIndex
int getIndex()Get the index of theParameterfor this context within the parameter list of theExecutablethat declares the parameter.- Returns:
- the index of the parameter
- See Also:
-
getDeclaringExecutable
- Returns:
- the declaring
Executable; nevernull - See Also:
-
getTarget
Get the target on which theExecutablethat declares theParameterfor this context will be invoked, if available.- Returns:
- an
Optionalcontaining the target on which theExecutablewill be invoked; nevernullbut will be empty if theExecutableis a constructor or astaticmethod.
-
getAnnotatedElement
Get theAnnotatedElementfor this context.WARNING
When searching for annotations on the annotated element in this context, favor
AnnotatedElementContext.isAnnotated(Class),AnnotatedElementContext.findAnnotation(Class), andAnnotatedElementContext.findRepeatableAnnotations(Class)over methods in theAnnotatedElementAPI due to a bug injavacon JDK versions prior to JDK 9.- Specified by:
getAnnotatedElementin interfaceAnnotatedElementContext- Returns:
- the annotated element; never
null - Since:
- 5.10
-
isAnnotated
@API(status=STABLE, since="5.10") default boolean isAnnotated(Class<? extends Annotation> annotationType) Determine 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- Parameters:
annotationType- the annotation type to search for; nevernull- Returns:
trueif the annotation is present or meta-present- Since:
- 5.1.1
- See Also:
-
findAnnotation
@API(status=STABLE, since="5.10") default <A extends Annotation> Optional<A> findAnnotation(Class<A> annotationType) Find 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- Type Parameters:
A- the annotation type- Parameters:
annotationType- the annotation type to search for; nevernull- Returns:
- an
Optionalcontaining the annotation; nevernullbut potentially empty - Since:
- 5.1.1
- See Also:
-
findRepeatableAnnotations
@API(status=STABLE, since="5.10") default <A extends Annotation> List<A> findRepeatableAnnotations(Class<A> annotationType) Find 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- 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 - Since:
- 5.1.1
- See Also:
-