@API(status=STABLE,
since="5.0")
public interface ParameterContext
extends 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.
ParameterResolver,
Parameter,
Executable,
Method,
Constructor| Modifier and Type | Method and Description |
|---|---|
default <A extends java.lang.annotation.Annotation> |
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> |
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. |
java.lang.reflect.Parameter getParameter()
Parameter for this context.
When searching for annotations on the parameter in this context,
favor isAnnotated(Class), findAnnotation(Class), and
findRepeatableAnnotations(Class) over methods in the
Parameter API due to a bug in javac on JDK versions prior
to JDK 9.
nullgetIndex()int getIndex()
Parameter for this context within the
parameter list of the Executable that
declares the parameter.getParameter(),
Executable.getParameters()default java.lang.reflect.Executable getDeclaringExecutable()
Executable (i.e., the Method or
Constructor) that declares the Parameter
for this context.Executable; never nullParameter.getDeclaringExecutable()java.util.Optional<java.lang.Object> getTarget()
Executable
that declares the Parameter for this context will
be invoked, if available.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.@API(status=EXPERIMENTAL,
since="5.10")
default java.lang.reflect.AnnotatedElement getAnnotatedElement()
AnnotatedElement for this context.
When searching for annotations on the annotated element in this context,
favor AnnotatedElementContext.isAnnotated(Class), AnnotatedElementContext.findAnnotation(Class), and
AnnotatedElementContext.findRepeatableAnnotations(Class) over methods in the
AnnotatedElement API due to a bug in javac on JDK versions prior
to JDK 9.
getAnnotatedElement in interface AnnotatedElementContextnull@API(status=STABLE,
since="5.10")
default boolean isAnnotated(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
annotationType is either
present or meta-present on the AnnotatedElement for
this context.
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.
isAnnotated in interface AnnotatedElementContextannotationType - the annotation type to search for; never nulltrue if the annotation is present or meta-presentAnnotatedElementContext.findAnnotation(Class),
AnnotatedElementContext.findRepeatableAnnotations(Class)@API(status=STABLE,
since="5.10")
default <A extends java.lang.annotation.Annotation> java.util.Optional<A> findAnnotation(java.lang.Class<A> annotationType)
annotationType that is either
present or meta-present on the AnnotatedElement for
this context.
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.
findAnnotation in interface AnnotatedElementContextA - the annotation typeannotationType - the annotation type to search for; never nullOptional containing the annotation; never null but
potentially emptyAnnotatedElementContext.isAnnotated(Class),
AnnotatedElementContext.findRepeatableAnnotations(Class)@API(status=STABLE,
since="5.10")
default <A extends java.lang.annotation.Annotation> java.util.List<A> findRepeatableAnnotations(java.lang.Class<A> annotationType)
annotationType that are either present or
meta-present on the AnnotatedElement for this context.
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.
findRepeatableAnnotations in interface AnnotatedElementContextA - the annotation typeannotationType - the repeatable annotation type to search for; never
nullnull nor
mutable, but potentially emptyAnnotatedElementContext.isAnnotated(Class),
AnnotatedElementContext.findAnnotation(Class),
Repeatable