Interface ParameterContext
-
@API(status=STABLE, since="5.0") public interface ParameterContext
ParameterContextencapsulates the context in which anExecutablewill be invoked for a givenParameter.A
ParameterContextis used to support parameter resolution via aParameterResolver.- Since:
- 5.0
- See Also:
ParameterResolver,Parameter,Executable,Method,Constructor
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <A extends Annotation>
Optional<A>findAnnotation(Class<A> annotationType)Find the first annotation ofannotationTypethat is either present or meta-present on theParameterfor this context.<A extends Annotation>
List<A>findRepeatableAnnotations(Class<A> annotationType)Find all repeatable annotations ofannotationTypethat are either present or meta-present on theParameterfor this context.default ExecutablegetDeclaringExecutable()intgetIndex()Get the index of theParameterfor this context within the parameter list of theExecutablethat declares the parameter.ParametergetParameter()Get theParameterfor this context.Optional<Object>getTarget()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 theParameterfor this context.
-
-
-
Method Detail
-
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()
-
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:
getParameter(),Executable.getParameters()
-
getDeclaringExecutable
default Executable getDeclaringExecutable()
- Returns:
- the declaring
Executable; nevernull - See Also:
Parameter.getDeclaringExecutable()
-
getTarget
Optional<Object> 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.
-
isAnnotated
boolean isAnnotated(Class<? extends Annotation> annotationType)
Determine if an annotation ofannotationTypeis either present or meta-present on theParameterfor 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.- 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(Class),findRepeatableAnnotations(Class)
-
findAnnotation
<A extends Annotation> Optional<A> findAnnotation(Class<A> annotationType)
Find the first annotation ofannotationTypethat is either present or meta-present on theParameterfor this context.WARNING
Favor the use of this method over directly invoking annotation lookup methods in the
ParameterAPI due to a bug injavacon JDK versions prior to JDK 9.- 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:
isAnnotated(Class),findRepeatableAnnotations(Class)
-
findRepeatableAnnotations
<A extends Annotation> List<A> findRepeatableAnnotations(Class<A> annotationType)
Find all repeatable annotations ofannotationTypethat are either present or meta-present on theParameterfor this context.WARNING
Favor the use of this method over directly invoking annotation lookup methods in the
ParameterAPI due to a bug injavacon 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
nullnor mutable, but potentially empty - Since:
- 5.1.1
- See Also:
isAnnotated(Class),findAnnotation(Class),Repeatable
-
-