Class ReflectionExecutables
java.lang.Object
io.micronaut.reflection.ReflectionExecutables
The adapters of a specification API that names an executable by its
Method or Constructor:
the generated metadata is used when it describes the named executable, and the reflective metadata of this
package otherwise - the one reflective step an API defined on java.lang.reflect imposes. The reverse
lookups resolve an executable method back to the Method it describes.- Since:
- 5.2.0
- Author:
- Denis Stepanov
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> BeanConstructor<T> beanConstructor(@Nullable BeanIntrospection<T> introspection, Constructor<T> constructor) The constructor named by the caller, with its arguments and its annotation metadata: the one the introspection describes when it describes that constructor, else one read from the constructor itself.static Argument<?>[]constructorArguments(BeanIntrospection<?> introspection, Constructor<?> constructor) The arguments of the constructor named by the caller: the ones the introspection describes when it describes that constructor, else the ones read from the constructor itself.static <T> ExecutableMethod<T, Object> executableMethod(BeanContext context, Method method) The executable method of the method named by the caller, resolved against the beans of a context and the introspections of its class loader.static <T> ExecutableMethod<T, Object> executableMethod(ExecutionHandleLocator locator, BeanIntrospector introspector, Method method) The executable method of the method named by the caller: the one of the bean definition when the declaring type is a bean, else the one of the bean introspection, generated or reflective, else one read from the method itself.static <T> MethodExecutionHandle<T, Object> executionHandle(ExecutionHandleLocator locator, BeanIntrospector introspector, T bean, Method method) An execution handle invoking the method named by the caller on a bean, with the best metadata available for the method.static <T> MethodExecutionHandle<T, Object> executionHandle(T bean, Method method) An execution handle invoking a method on a bean reflectively.findMethod(Class<?> type, String name, Class<?>... parameterTypes) Finds the method a type reads under a name, whether the type declares it or inherits it from a super class or an interface, of any visibility, static or not.static MethodtargetMethod(MethodReference<?, ?> method) TheMethodan executable method describes.
-
Method Details
-
executableMethod
public static <T> ExecutableMethod<T,Object> executableMethod(ExecutionHandleLocator locator, BeanIntrospector introspector, Method method) The executable method of the method named by the caller: the one of the bean definition when the declaring type is a bean, else the one of the bean introspection, generated or reflective, else one read from the method itself.- Type Parameters:
T- The declaring type- Parameters:
locator- The locator of the executable methods of the beansintrospector- The introspectormethod- The method- Returns:
- The executable method
-
executableMethod
The executable method of the method named by the caller, resolved against the beans of a context and the introspections of its class loader.- Type Parameters:
T- The declaring type- Parameters:
context- The bean contextmethod- The method- Returns:
- The executable method
- See Also:
-
executionHandle
public static <T> MethodExecutionHandle<T,Object> executionHandle(ExecutionHandleLocator locator, BeanIntrospector introspector, T bean, Method method) An execution handle invoking the method named by the caller on a bean, with the best metadata available for the method.- Type Parameters:
T- The declaring type- Parameters:
locator- The locator of the executable methods of the beansintrospector- The introspectorbean- The beanmethod- The method- Returns:
- The execution handle
- See Also:
-
executionHandle
An execution handle invoking a method on a bean reflectively.- Type Parameters:
T- The declaring type- Parameters:
bean- The beanmethod- The method- Returns:
- The execution handle
-
constructorArguments
public static Argument<?>[] constructorArguments(BeanIntrospection<?> introspection, Constructor<?> constructor) The arguments of the constructor named by the caller: the ones the introspection describes when it describes that constructor, else the ones read from the constructor itself.- Parameters:
introspection- The introspection of the declaring typeconstructor- The constructor- Returns:
- The arguments
-
beanConstructor
public static <T> BeanConstructor<T> beanConstructor(@Nullable BeanIntrospection<T> introspection, Constructor<T> constructor) The constructor named by the caller, with its arguments and its annotation metadata: the one the introspection describes when it describes that constructor, else one read from the constructor itself. A generated introspection describes every constructor when compiled with@Introspected(constructors = true), aReflectiveIntrospectionalways does.- Type Parameters:
T- The declaring type- Parameters:
introspection- The introspection of the declaring type, can benullconstructor- The constructor- Returns:
- The bean constructor
-
targetMethod
TheMethodan executable method describes. The method the reference reports is returned when it resolves; otherwise the method is found by name and parameter types in the hierarchy of the declaring type, tolerating the erasure: the arguments of a method inherited from a generic super type report the resolved types, where the method declares the erased ones.- Parameters:
method- The executable method, or any method reference- Returns:
- The method
- Throws:
NoSuchMethodError- When no method of the declaring type matches
-
findMethod
Finds the method a type reads under a name, whether the type declares it or inherits it from a super class or an interface, of any visibility, static or not. A method whose parameters are exactly the given types wins; failing that, a method whose parameters are assignable from them - the erasure of a generic declaration - with the same arity. Where more than one declaration applies, the most specific one wins, so the answer does not depend on the order in which a type reports its methods.- Parameters:
type- The typename- The method nameparameterTypes- The parameter types- Returns:
- The method, empty when the type has none
-