public final class MethodFinder extends Object
Constructor and Description |
---|
MethodFinder(Class<?> clazz) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
Constructor<?> |
findConstructor(Class<?>[] parameterTypes)
Returns the most specific public constructor in my target class that
accepts the number and type of parameters in the given Class array in a
reflective invocation.
|
Method |
findMethod(String methodName,
Class<?>[] parameterTypes)
Returns the most specific public method in my target class that has the
given name and accepts the number and type of parameters in the given
Class array in a reflective invocation.
|
static Class<?>[] |
getParameterTypesFrom(Object[] args) |
static Class<?>[] |
getParameterTypesFrom(String[] classNames) |
static Class<?>[] |
getParameterTypesFrom(String[] classNames,
ClassLoader loader) |
int |
hashCode() |
public MethodFinder(Class<?> clazz)
clazz
- Class in which I will look for methods and constructors
throws IllegalArgumentException if clazz is null, or represents a primitive, or represents an array typepublic boolean equals(Object o)
equals
in class Object
Object.equals(java.lang.Object)
public Constructor<?> findConstructor(Class<?>[] parameterTypes) throws NoSuchMethodException
A null value or Void.TYPE in parameterTypes matches a corresponding Object or array reference in a constructor's formal parameter list, but not a primitive formal parameter.
parameterTypes
- array representing the number and types of
parameters to look for in the constructor's signature. A null
array is treated as a zero-length array.NoSuchMethodException
- if no constructors match the criteria,
or if the reflective call is ambiguous based on the
parameter typespublic Method findMethod(String methodName, Class<?>[] parameterTypes) throws NoSuchMethodException
A null value or Void.TYPE in parameterTypes will match a corresponding Object or array reference in a method's formal parameter list, but not a primitive formal parameter.
methodName
- name of the method to search forparameterTypes
- array representing the number and types of
parameters to look for in the method's signature. A null array
is treated as a zero-length array.NoSuchMethodException
- if no methods match the criteria, or if
the reflective call is ambiguous based on the parameter
types, or if methodName is nullpublic static Class<?>[] getParameterTypesFrom(Object[] args)
args
- an Object arraypublic static Class<?>[] getParameterTypesFrom(String[] classNames) throws ClassNotFoundException
classNames
- String array of fully qualified names (FQNs) of classes
or primitives. Represent an array type by using its JVM type
descriptor, with dots instead of slashes (e.g. represent the
type int[] with "[I", and Object[][] with
"[[Ljava.lang.Object;").ClassNotFoundException
- if any of the FQNs name an unknown
classpublic static Class<?>[] getParameterTypesFrom(String[] classNames, ClassLoader loader) throws ClassNotFoundException
classNames
- String array of fully qualified names (FQNs) of classes
or primitives. Represent an array type by using its JVM type
descriptor, with dots instead of slashes (e.g. represent the
type int[] with "[I", and Object[][] with
"[[Ljava.lang.Object;").loader
- a ClassLoaderClassNotFoundException
- if any of the FQNs name an unknown
classpublic int hashCode()
hashCode
in class Object
Object.hashCode()