class DefaultParameterContext extends java.lang.Object implements ParameterContext
| Modifier and Type | Field and Description |
|---|---|
private int |
index |
private java.lang.reflect.Parameter |
parameter |
private java.util.Optional<java.lang.Object> |
target |
| Constructor and Description |
|---|
DefaultParameterContext(java.lang.reflect.Parameter parameter,
int index,
java.util.Optional<java.lang.Object> target) |
| Modifier and Type | Method and Description |
|---|---|
<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. |
<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. |
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. |
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.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetAnnotatedElement, getDeclaringExecutableprivate final java.lang.reflect.Parameter parameter
private final int index
private final java.util.Optional<java.lang.Object> target
DefaultParameterContext(java.lang.reflect.Parameter parameter,
int index,
java.util.Optional<java.lang.Object> target)
public java.lang.reflect.Parameter getParameter()
ParameterContextParameter for this context.
When searching for annotations on the parameter in this context,
favor ParameterContext.isAnnotated(Class), ParameterContext.findAnnotation(Class), and
ParameterContext.findRepeatableAnnotations(Class) over methods in the
Parameter API due to a bug in javac on JDK versions prior
to JDK 9.
getParameter in interface ParameterContextnullParameterContext.getIndex()public int getIndex()
ParameterContextParameter for this context within the
parameter list of the Executable that
declares the parameter.getIndex in interface ParameterContextParameterContext.getParameter(),
Executable.getParameters()public java.util.Optional<java.lang.Object> getTarget()
ParameterContextExecutable
that declares the Parameter for this context will
be invoked, if available.getTarget in interface ParameterContextOptional 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.public boolean isAnnotated(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
ParameterContextannotationType 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 AnnotatedElementContextisAnnotated in interface ParameterContextannotationType - the annotation type to search for; never nulltrue if the annotation is present or meta-presentAnnotatedElementContext.findAnnotation(Class),
AnnotatedElementContext.findRepeatableAnnotations(Class)public <A extends java.lang.annotation.Annotation> java.util.Optional<A> findAnnotation(java.lang.Class<A> annotationType)
ParameterContextannotationType 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 AnnotatedElementContextfindAnnotation in interface ParameterContextA - the annotation typeannotationType - the annotation type to search for; never nullOptional containing the annotation; never null but
potentially emptyAnnotatedElementContext.isAnnotated(Class),
AnnotatedElementContext.findRepeatableAnnotations(Class)public <A extends java.lang.annotation.Annotation> java.util.List<A> findRepeatableAnnotations(java.lang.Class<A> annotationType)
ParameterContextannotationType 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 AnnotatedElementContextfindRepeatableAnnotations in interface ParameterContextA - the annotation typeannotationType - the repeatable annotation type to search for; never
nullnull nor
mutable, but potentially emptyAnnotatedElementContext.isAnnotated(Class),
AnnotatedElementContext.findAnnotation(Class),
Repeatablepublic java.lang.String toString()
toString in class java.lang.Object