@API(status=INTERNAL,
since="5.0")
public class ExecutableInvoker
extends java.lang.Object
ExecutableInvoker encapsulates the invocation of a
Executable (i.e., method or constructor),
including support for dynamic resolution of method parameters via
ParameterResolvers.| Constructor and Description |
|---|
ExecutableInvoker() |
| Modifier and Type | Method and Description |
|---|---|
private static java.lang.String |
asLabel(java.lang.reflect.Executable executable) |
<T> T |
invoke(java.lang.reflect.Constructor<T> constructor,
ExtensionContext extensionContext,
ExtensionRegistry extensionRegistry)
Invoke the supplied constructor with dynamic parameter resolution.
|
<T> T |
invoke(java.lang.reflect.Constructor<T> constructor,
java.lang.Object outerInstance,
ExtensionContext extensionContext,
ExtensionRegistry extensionRegistry)
Invoke the supplied constructor with the supplied outer instance and
dynamic parameter resolution.
|
java.lang.Object |
invoke(java.lang.reflect.Method method,
ExtensionContext extensionContext,
ExtensionRegistry extensionRegistry)
Invoke the supplied
static method with dynamic parameter resolution. |
java.lang.Object |
invoke(java.lang.reflect.Method method,
java.lang.Object target,
ExtensionContext extensionContext,
ExtensionRegistry extensionRegistry)
Invoke the supplied method on the supplied target object with dynamic parameter
resolution.
|
private java.lang.Object |
resolveParameter(ParameterContext parameterContext,
java.lang.reflect.Executable executable,
ExtensionContext extensionContext,
ExtensionRegistry extensionRegistry) |
private java.lang.Object[] |
resolveParameters(java.lang.reflect.Executable executable,
java.util.Optional<java.lang.Object> target,
ExtensionContext extensionContext,
ExtensionRegistry extensionRegistry)
Resolve the array of parameters for the supplied executable and target.
|
private java.lang.Object[] |
resolveParameters(java.lang.reflect.Executable executable,
java.util.Optional<java.lang.Object> target,
java.lang.Object outerInstance,
ExtensionContext extensionContext,
ExtensionRegistry extensionRegistry)
Resolve the array of parameters for the supplied executable, target, and
outer instance.
|
private void |
validateResolvedType(java.lang.reflect.Parameter parameter,
java.lang.Object value,
java.lang.reflect.Executable executable,
ParameterResolver resolver) |
private static final Logger logger
public <T> T invoke(java.lang.reflect.Constructor<T> constructor,
ExtensionContext extensionContext,
ExtensionRegistry extensionRegistry)
constructor - the constructor to invoke and resolve parameters forextensionContext - the current ExtensionContextextensionRegistry - the ExtensionRegistry to retrieve
ParameterResolvers frompublic <T> T invoke(java.lang.reflect.Constructor<T> constructor,
java.lang.Object outerInstance,
ExtensionContext extensionContext,
ExtensionRegistry extensionRegistry)
This method should only be used to invoke the constructor for an inner class.
constructor - the constructor to invoke and resolve parameters forouterInstance - the outer instance to supply as the first argument
to the constructorextensionContext - the current ExtensionContextextensionRegistry - the ExtensionRegistry to retrieve
ParameterResolvers frompublic java.lang.Object invoke(java.lang.reflect.Method method,
ExtensionContext extensionContext,
ExtensionRegistry extensionRegistry)
static method with dynamic parameter resolution.method - the method to invoke and resolve parameters forextensionContext - the current ExtensionContextextensionRegistry - the ExtensionRegistry to retrieve
ParameterResolvers frompublic java.lang.Object invoke(java.lang.reflect.Method method,
java.lang.Object target,
ExtensionContext extensionContext,
ExtensionRegistry extensionRegistry)
method - the method to invoke and resolve parameters fortarget - the object on which the method will be invoked; should be
null for static methodsextensionContext - the current ExtensionContextextensionRegistry - the ExtensionRegistry to retrieve
ParameterResolvers fromprivate java.lang.Object[] resolveParameters(java.lang.reflect.Executable executable,
java.util.Optional<java.lang.Object> target,
ExtensionContext extensionContext,
ExtensionRegistry extensionRegistry)
executable - the executable for which to resolve parameterstarget - an Optional containing the target on which the
executable will be invoked; never null but should be empty for
static methods and constructorsextensionContext - the current ExtensionContextextensionRegistry - the ExtensionRegistry to retrieve
ParameterResolvers fromnull though potentially emptyprivate java.lang.Object[] resolveParameters(java.lang.reflect.Executable executable,
java.util.Optional<java.lang.Object> target,
java.lang.Object outerInstance,
ExtensionContext extensionContext,
ExtensionRegistry extensionRegistry)
executable - the executable for which to resolve parameterstarget - an Optional containing the target on which the
executable will be invoked; never null but should be empty for
static methods and constructorsouterInstance - the outer instance that will be supplied as the
first argument to a constructor for an inner class; should be null
for methods and constructors for top-level or static classesextensionContext - the current ExtensionContextextensionRegistry - the ExtensionRegistry to retrieve
ParameterResolvers fromnull though potentially emptyprivate java.lang.Object resolveParameter(ParameterContext parameterContext, java.lang.reflect.Executable executable, ExtensionContext extensionContext, ExtensionRegistry extensionRegistry)
private void validateResolvedType(java.lang.reflect.Parameter parameter,
java.lang.Object value,
java.lang.reflect.Executable executable,
ParameterResolver resolver)
private static java.lang.String asLabel(java.lang.reflect.Executable executable)