public class Methods
extends java.lang.Object
| Constructor and Description |
|---|
Methods() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.reflect.Method |
getDeclaredMethod(java.lang.Class<?> clazz,
java.lang.String name,
java.lang.Class<?>... parameterTypes)
Get a declared method of a class by its name and parameter types.
|
static java.lang.reflect.Method[] |
getDeclaredMethods(java.lang.Class<?> clazz)
Get all declared methods of a class.
|
static <T> T |
invoke(java.lang.Object instance,
java.lang.reflect.Method method,
java.lang.Object... args)
Invoke a method without any checks.
|
static <I extends S,S,T> |
invokeSuper(I instance,
java.lang.Class<S> superClass,
java.lang.reflect.Method method,
java.lang.Object... args)
Invoke a super method without any checks.
|
public static java.lang.reflect.Method[] getDeclaredMethods(java.lang.Class<?> clazz)
clazz - The class to get the methods fromMethodNotFoundException - If the Class internal getDeclaredMethods0 method could not be found@Nullable
public static java.lang.reflect.Method getDeclaredMethod(java.lang.Class<?> clazz,
java.lang.String name,
java.lang.Class<?>... parameterTypes)
clazz - The class to get the method fromname - The name of the methodparameterTypes - The parameter types of the methodpublic static <T> T invoke(@Nullable
java.lang.Object instance,
java.lang.reflect.Method method,
java.lang.Object... args)
T - The return type of the methodinstance - The instance to invoke the method onmethod - The method to invokeargs - The arguments to pass to the methodMethodInvocationException - If the method could not be invokedpublic static <I extends S,S,T> T invokeSuper(@Nonnull
I instance,
@Nonnull
java.lang.Class<S> superClass,
java.lang.reflect.Method method,
java.lang.Object... args)
I - The type of the instanceS - The type of the super classT - The return type of the methodinstance - The instance to invoke the method onsuperClass - The super class to call the method ofmethod - The method to invokeargs - The arguments to pass to the methodjava.lang.IllegalStateException - If the method is staticMethodInvocationException - If the method could not be invoked