类 ReflectionUtils
- 从以下版本开始:
- 2.1.7
- 作者:
- TODAY 2020-08-13 18:45
-
嵌套类概要
嵌套类修饰符和类型类说明static interfaceCallback interface invoked on each field in the hierarchy.static interfaceCallback optionally used to filter fields to be operated on by a field callback.static interfaceAction to take on each method.static interfaceCallback optionally used to filter methods to be operated on by a method callback. -
字段概要
字段修饰符和类型字段说明static final StringNaming prefix for CGLIB-renamed methods.static final ReflectionUtils.FieldFilterPre-built FieldFilter that matches all non-static, non-final fields.static final ReflectionUtils.MethodFilterPre-built MethodFilter that matches all non-bridge non-synthetic methods which are not declared onjava.lang.Object. -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static <T> Constructor<T>accessibleConstructor(Class<T> targetClass, Class<?>... parameterTypes) static voidClear the internal method/field cache.static voidCopy a given field from the source object to the destinationstatic booleandeclaresException(Method method, Class<?> exceptionType) Determine whether the given method explicitly declares the given exception or one of its superclasses, which means that an exception of that type can be propagated as-is within a reflective invocation.static voiddoWithFields(Class<?> clazz, ReflectionUtils.FieldCallback fc) Invoke the given callback on all fields in the target class, going up the class hierarchy to get all declared fields.static voiddoWithFields(Class<?> clazz, ReflectionUtils.FieldCallback fc, ReflectionUtils.FieldFilter ff) Invoke the given callback on all fields in the target class, going up the class hierarchy to get all declared fields.static voiddoWithLocalFields(Class<?> clazz, ReflectionUtils.FieldCallback fc) Invoke the given callback on all locally declared fields in the given class.static voiddoWithLocalMethods(Class<?> clazz, ReflectionUtils.MethodCallback mc) Perform the given callback operation on all matching methods of the given class, as locally declared or equivalent thereof (such as default methods on Java 8 based interfaces that the given class implements).static voiddoWithMethods(Class<?> clazz, ReflectionUtils.MethodCallback mc) Perform the given callback operation on all matching methods of the given class and superclasses.static voiddoWithMethods(Class<?> clazz, ReflectionUtils.MethodCallback mc, ReflectionUtils.MethodFilter mf) Perform the given callback operation on all matching methods of the given class and superclasses (or given interface and super-interfaces).static MethodfindDeclaredMethodWithMinimalParameters(Class<?> clazz, String methodName) Find a method with the given method name and minimal parameters (best case: none), declared on the given class or one of its superclasses.static Fieldstatic Fieldstatic MethodFind the method from FunctionalInterfacestatic MethodfindMethod(Class<?> clazz, String name) Attempt to find aMethodon the supplied class with the supplied name and no parameters.static MethodfindMethod(Class<?> clazz, String name, Class<?>... paramTypes) Attempt to find aMethodon the supplied class with the supplied name and parameter types.static MethodfindMethodWithMinimalParameters(Class<?> clazz, String methodName) Find a method with the given method name and minimal parameters (best case: none), declared on the given class or one of its superclasses.static MethodfindMethodWithMinimalParameters(Method[] methods, String methodName) Find a method with the given method name and minimal parameters (best case: none) in the given list of methods.static Method[]getAllDeclaredMethods(Class<?> leafClass) Get all declared methods on the leaf class and all superclasses.static <T> Constructor<T>getConstructor(Class<T> type, Class<?>... parameterTypes) getDeclaredConstructorstatic <T> Constructor<T>getConstructorIfAvailable(Class<T> clazz, Class<?>... paramTypes) Determine whether the given class has a declared constructor with the given signature, and return it if available (else returnnull).static Field[]getDeclaredFields(Class<?> clazz) This variant retrievesClass.getDeclaredFields()from a local cache in order to avoid the JVM's SecurityManager check and defensive array copying.static Method[]getDeclaredMethods(Class<?> targetClass) Variant ofClass.getDeclaredMethods()that uses a local cache in order to avoid the JVM's SecurityManager check and new Method instances.static ObjectGet the field represented by the suppliedfield objecton the specifiedtarget object.static MethodgetInterfaceMethodIfPossible(Method method) Determine a corresponding interface method for the given method handle, if possible.static MethodgetInterfaceMethodIfPossible(Method method, Class<?> targetClass) Determine a corresponding interface method for the given method handle, if possible.static MethodDetermine whether the given class has a public method with the given signature, and return it if available (else throws anIllegalStateException).static intgetMethodCountForName(Class<?> clazz, String methodName) Return the number of methods with a given name (with any argument types), for the given class and/or its superclasses.static MethodgetMethodIfAvailable(Class<?> clazz, String methodName, Class<?>... paramTypes) Determine whether the given class has a public method with the given signature, and return it if available (else returnnull).static MethodgetMostSpecificMethod(Method method, Class<?> targetClass) Given a method, which may come from an interface, and a target class used in the current reflective invocation, find the corresponding target method if there is one.static ParametergetParameter(Executable executable, int parameterIndex) GetParameterwith givenparameterIndexstatic intgetParameterIndex(Parameter parameter) GetParameterindexstatic StringgetPropertyName(Method readMethod, Method writeMethod) get property name from readMethod or writeMethodstatic ProtectionDomaingetProtectionDomain(Class<?> source) static MethodgetReadMethod(Class<?> declaredClass, Class<?> type, String name) find getter methodstatic MethodgetReadMethod(Field field) find getter methodstatic MethodgetStaticMethod(Class<?> clazz, String methodName, Class<?>... args) Return a public static method of a class.static Method[]getUniqueDeclaredMethods(Class<?> leafClass) Get the unique set of declared methods on the leaf class and all superclasses.static Method[]getUniqueDeclaredMethods(Class<?> leafClass, ReflectionUtils.MethodFilter mf) Get the unique set of declared methods on the leaf class and all superclasses.static MethodgetWriteMethod(Class<?> declaredClass, Class<?> type, String name) find setter methodstatic MethodgetWriteMethod(Field field) find setter methodstatic voidHandle the given invocation target exception.static voidHandle the given reflection exception.static booleanhasConstructor(Class<?> clazz, Class<?>... paramTypes) Determine whether the given class has a declared constructor with the given signature.static booleanDetermine whether the given class has a public method with the given signature.static booleanDetermine whether the given class has a public method with the given signature.static <T> TinvokeConstructor(Constructor<T> constructor, Object[] args) static ObjectinvokeMethod(Method method, Object target) Invoke the specifiedMethodagainst the supplied target object with no arguments.static ObjectinvokeMethod(Method method, Object target, Object... args) Invoke the specifiedMethodagainst the supplied target object with the supplied arguments.static booleanisCglibRenamedMethod(Method renamedMethod) Determine whether the given method is a CGLIB 'renamed' method, following the pattern "CGLIB$methodName$0".static booleanisEqualsMethod(Method method) Determine whether the given method is an "equals" method.static booleanisFinalizeMethod(Method method) Determine whether the given method is a "finalize" method.static booleanisHashCodeMethod(Method method) Determine whether the given method is a "hashCode" method.static booleanisObjectMethod(Method method) Determine whether the given method is originally declared byObject.static booleanisPublicStaticFinal(Field field) Determine whether the given field is a "public static final" constant.static booleanisToStringMethod(Method method) Determine whether the given method is a "toString" method.static <T> Constructor<T>makeAccessible(Constructor<T> constructor) static FieldmakeAccessible(Field field) Make the given field accessible, explicitly setting it accessible if necessary.static MethodmakeAccessible(Method method) Make the given method accessible, explicitly setting it accessible if necessary.static <T> TnewInstance(Class<T> type) static <T> TnewInstance(Class<T> type, Class[] parameterTypes, Object[] args) static <T> TnewInstance(String beanClassName) Get instance with bean classstatic FieldobtainField(Class<?> clazz, String name) static MethodobtainMethod(Class<?> targetClass, String methodName, Class<?>... parameterTypes) static voidRethrow the givenexception, which is presumably the target exception of anInvocationTargetException.static voidRethrow the givenexception, which is presumably the target exception of anInvocationTargetException.static voidSet the field represented by the supplied field object on the specified target object to the specifiedvalue.static voidshallowCopyFieldState(Object src, Object dest) Given the source object and the destination, which must be the same class or a subclass, copy all fields, including inherited fields.static Field[]toFieldArray(Collection<Field> fields) static Method[]toMethodArray(Collection<Method> collection) Copy the givenCollectioninto aMethodarray.
-
字段详细资料
-
USER_DECLARED_METHODS
Pre-built MethodFilter that matches all non-bridge non-synthetic methods which are not declared onjava.lang.Object. -
COPYABLE_FIELDS
Pre-built FieldFilter that matches all non-static, non-final fields. -
CGLIB_RENAMED_METHOD_PREFIX
Naming prefix for CGLIB-renamed methods.
-
-
构造器详细资料
-
ReflectionUtils
public ReflectionUtils()
-
-
方法详细资料
-
handleReflectionException
Handle the given reflection exception.Should only be called if no checked exception is expected to be thrown by a target method, or if an error occurs while accessing a method or field.
Throws the underlying RuntimeException or Error in case of an InvocationTargetException with such a root cause. Throws an IllegalStateException with an appropriate message or UndeclaredThrowableException otherwise.
- 参数:
ex- the reflection exception to handle
-
handleInvocationTargetException
Handle the given invocation target exception. Should only be called if no checked exception is expected to be thrown by the target method.Throws the underlying RuntimeException or Error in case of such a root cause. Throws an UndeclaredThrowableException otherwise.
- 参数:
ex- the invocation target exception to handle
-
rethrowRuntimeException
Rethrow the givenexception, which is presumably the target exception of anInvocationTargetException. Should only be called if no checked exception is expected to be thrown by the target method.Rethrows the underlying exception cast to a
RuntimeExceptionorErrorif appropriate; otherwise, throws anUndeclaredThrowableException.- 参数:
ex- the exception to rethrow- 抛出:
RuntimeException- the rethrown exception
-
rethrowException
Rethrow the givenexception, which is presumably the target exception of anInvocationTargetException. Should only be called if no checked exception is expected to be thrown by the target method.Rethrows the underlying exception cast to an
ExceptionorErrorif appropriate; otherwise, throws anUndeclaredThrowableException.- 参数:
ex- the exception to rethrow- 抛出:
Exception- the rethrown exception (in case of a checked exception)
-
hasMethod
Determine whether the given class has a public method with the given signature.Essentially translates
NoSuchMethodExceptionto "false".- 参数:
clazz- the clazz to analyzemethodName- the name of the methodparamTypes- the parameter types of the method- 返回:
- whether the class has a corresponding method
- 从以下版本开始:
- 4.0
- 另请参阅:
-
getMethod
Determine whether the given class has a public method with the given signature, and return it if available (else throws anIllegalStateException).In case of any signature specified, only returns the method if there is a unique candidate, i.e. a single public method with the specified name.
Essentially translates
NoSuchMethodExceptiontoIllegalStateException.- 参数:
clazz- the clazz to analyzemethodName- the name of the methodparamTypes- the parameter types of the method (may benullto indicate any signature)- 返回:
- the method (never
null) - 抛出:
IllegalStateException- if the method has not been found- 从以下版本开始:
- 4.0
- 另请参阅:
-
getMethodIfAvailable
@Nullable public static Method getMethodIfAvailable(Class<?> clazz, String methodName, @Nullable Class<?>... paramTypes) Determine whether the given class has a public method with the given signature, and return it if available (else returnnull).In case of any signature specified, only returns the method if there is a unique candidate, i.e. a single public method with the specified name.
Essentially translates
NoSuchMethodExceptiontonull.- 参数:
clazz- the clazz to analyzemethodName- the name of the methodparamTypes- the parameter types of the method (may benullto indicate any signature)- 返回:
- the method, or
nullif not found - 从以下版本开始:
- 4.0
- 另请参阅:
-
getMethodCountForName
Return the number of methods with a given name (with any argument types), for the given class and/or its superclasses. Includes non-public methods.- 参数:
clazz- the clazz to checkmethodName- the name of the method- 返回:
- the number of methods with the given name
- 从以下版本开始:
- 4.0
-
getStaticMethod
Return a public static method of a class.- 参数:
clazz- the class which defines the methodmethodName- the static method nameargs- the parameter types to the method- 返回:
- the static method, or
nullif no static method was found - 抛出:
IllegalArgumentException- if the method name is blank or the clazz is null
-
hasMethod
Determine whether the given class has a public method with the given signature.- 参数:
clazz- the clazz to analyzemethod- the method to look for- 返回:
- whether the class has a corresponding method
- 从以下版本开始:
- 3.0
-
getMostSpecificMethod
Given a method, which may come from an interface, and a target class used in the current reflective invocation, find the corresponding target method if there is one. E.g. the method may beIFoo.bar()and the target class may beDefaultFoo. In this case, the method may beDefaultFoo.bar(). This enables attributes on that method to be found.NOTE: In contrast to
cn.taketoday.aop.support.AopUtils#getMostSpecificMethod, this method does not resolve Java 5 bridge methods automatically. CallBridgeMethodResolver.findBridgedMethod(java.lang.reflect.Method)if bridge method resolution is desirable (e.g. for obtaining metadata from the original method definition).- 参数:
method- the method to be invoked, which may come from an interfacetargetClass- the target class for the current invocation (may benullor may not even implement the method)- 返回:
- the specific target method, or the original method if the
targetClassdoes not implement it - 从以下版本开始:
- 3.0
-
getInterfaceMethodIfPossible
Determine a corresponding interface method for the given method handle, if possible.This is particularly useful for arriving at a public exported type on Jigsaw which can be reflectively invoked without an illegal access warning.
- 参数:
method- the method to be invoked, potentially from an implementation class- 返回:
- the corresponding interface method, or the original method if none found
- 从以下版本开始:
- 4.0
- 另请参阅:
-
getInterfaceMethodIfPossible
Determine a corresponding interface method for the given method handle, if possible.This is particularly useful for arriving at a public exported type on Jigsaw which can be reflectively invoked without an illegal access warning.
- 参数:
method- the method to be invoked, potentially from an implementation classtargetClass- the target class to check for declared interfaces- 返回:
- the corresponding interface method, or the original method if none found
- 从以下版本开始:
- 4.0
- 另请参阅:
-
findMethod
Attempt to find aMethodon the supplied class with the supplied name and no parameters. Searches all superclasses up toObject.Returns
nullif noMethodcan be found.- 参数:
clazz- the class to introspectname- the name of the method- 返回:
- the Method object, or
nullif none found
-
findMethod
Attempt to find aMethodon the supplied class with the supplied name and parameter types. Searches all superclasses up toObject.Returns
nullif noMethodcan be found.- 参数:
clazz- the class to introspectname- the name of the methodparamTypes- the parameter types of the method (may benullto indicate any signature)- 返回:
- the Method object, or
nullif none found
-
findFunctionalInterfaceMethod
Find the method from FunctionalInterface- 抛出:
IllegalArgumentException- if given class is not a FunctionalInterface- 从以下版本开始:
- 4.0
- 另请参阅:
-
invokeMethod
Invoke the specifiedMethodagainst the supplied target object with no arguments. The target object can benullwhen invoking a staticMethod.Thrown exceptions are handled via a call to
handleReflectionException(java.lang.Exception).- 参数:
method- the method to invoketarget- the target object to invoke the method on- 返回:
- the invocation result, if any
- 另请参阅:
-
invokeMethod
Invoke the specifiedMethodagainst the supplied target object with the supplied arguments. The target object can benullwhen invoking a staticMethod.Thrown exceptions are handled via a call to
handleReflectionException(java.lang.Exception).- 参数:
method- the method to invoketarget- the target object to invoke the method onargs- the invocation arguments (may benull)- 返回:
- the invocation result, if any
-
declaresException
Determine whether the given method explicitly declares the given exception or one of its superclasses, which means that an exception of that type can be propagated as-is within a reflective invocation.- 参数:
method- the declaring methodexceptionType- the exception to throw- 返回:
trueif the exception can be thrown as-is;falseif it needs to be wrapped
-
doWithLocalMethods
Perform the given callback operation on all matching methods of the given class, as locally declared or equivalent thereof (such as default methods on Java 8 based interfaces that the given class implements).- 参数:
clazz- the class to introspectmc- the callback to invoke for each method- 抛出:
IllegalStateException- if introspection fails- 另请参阅:
-
doWithMethods
Perform the given callback operation on all matching methods of the given class and superclasses.The same named method occurring on subclass and superclass will appear twice, unless excluded by a
ReflectionUtils.MethodFilter.- 参数:
clazz- the class to introspectmc- the callback to invoke for each method- 抛出:
IllegalStateException- if introspection fails- 另请参阅:
-
doWithMethods
public static void doWithMethods(Class<?> clazz, ReflectionUtils.MethodCallback mc, @Nullable ReflectionUtils.MethodFilter mf) Perform the given callback operation on all matching methods of the given class and superclasses (or given interface and super-interfaces).The same named method occurring on subclass and superclass will appear twice, unless excluded by the specified
ReflectionUtils.MethodFilter.- 参数:
clazz- the class to introspectmc- the callback to invoke for each methodmf- the filter that determines the methods to apply the callback to- 抛出:
IllegalStateException- if introspection fails
-
getAllDeclaredMethods
Get all declared methods on the leaf class and all superclasses. Leaf class methods are included first.- 参数:
leafClass- the class to introspect- 抛出:
IllegalStateException- if introspection fails
-
getDeclaredMethods
Variant ofClass.getDeclaredMethods()that uses a local cache in order to avoid the JVM's SecurityManager check and new Method instances. In addition, it also includes Java 8 default methods from locally implemented interfaces, since those are effectively to be treated just like declared methods.- 参数:
targetClass- the class to introspect- 返回:
- the cached array of methods
- 抛出:
IllegalStateException- if introspection fails- 另请参阅:
-
getUniqueDeclaredMethods
Get the unique set of declared methods on the leaf class and all superclasses. Leaf class methods are included first and while traversing the superclass hierarchy any methods found with signatures matching a method already included are filtered out.- 参数:
leafClass- the class to introspect- 抛出:
IllegalStateException- if introspection fails
-
getUniqueDeclaredMethods
public static Method[] getUniqueDeclaredMethods(Class<?> leafClass, @Nullable ReflectionUtils.MethodFilter mf) Get the unique set of declared methods on the leaf class and all superclasses. Leaf class methods are included first and while traversing the superclass hierarchy any methods found with signatures matching a method already included are filtered out.- 参数:
leafClass- the class to introspectmf- the filter that determines the methods to take into account- 抛出:
IllegalStateException- if introspection fails
-
isEqualsMethod
Determine whether the given method is an "equals" method.- 另请参阅:
-
isHashCodeMethod
Determine whether the given method is a "hashCode" method.- 另请参阅:
-
isToStringMethod
Determine whether the given method is a "toString" method.- 另请参阅:
-
isObjectMethod
Determine whether the given method is originally declared byObject. -
isFinalizeMethod
Determine whether the given method is a "finalize" method.- 另请参阅:
-
isCglibRenamedMethod
Determine whether the given method is a CGLIB 'renamed' method, following the pattern "CGLIB$methodName$0".- 参数:
renamedMethod- the method to check
-
makeAccessible
Make the given method accessible, explicitly setting it accessible if necessary. ThesetAccessible(true)method is only called when actually necessary, to avoid unnecessary conflicts with a JVM SecurityManager (if active).- 参数:
method- the method to make accessible- 另请参阅:
-
toMethodArray
Copy the givenCollectioninto aMethodarray.The
Collectionmust containMethodelements only.- 参数:
collection- theCollectionto copy- 返回:
- the
Methodarray - 从以下版本开始:
- 4.0
- 另请参阅:
-
findField
Attempt to find afieldon the suppliedClasswith the suppliedname. Searches all superclasses up toObject.- 参数:
clazz- the class to introspectname- the name of the field- 返回:
- the corresponding Field object, or
nullif not found
-
findField
Attempt to find afieldon the suppliedClasswith the suppliednameand/ortype. Searches all superclasses up toObject.- 参数:
clazz- the class to introspectname- the name of the field (may benullif type is specified)type- the type of the field (may benullif name is specified)- 返回:
- the corresponding Field object, or
nullif not found
-
setField
Set the field represented by the supplied field object on the specified target object to the specifiedvalue.In accordance with
Field.set(Object, Object)semantics, the new value is automatically unwrapped if the underlying field has a primitive type.This method does not support setting
static finalfields.Thrown exceptions are handled via a call to
handleReflectionException(Exception).- 参数:
field- the field to settarget- the target object on which to set the fieldvalue- the value to set (may benull)
-
getField
Get the field represented by the suppliedfield objecton the specifiedtarget object. In accordance withField.get(Object)semantics, the returned value is automatically wrapped if the underlying field has a primitive type.Thrown exceptions are handled via a call to
handleReflectionException(Exception).- 参数:
field- the field to gettarget- the target object from which to get the field- 返回:
- the field's current value
-
doWithLocalFields
Invoke the given callback on all locally declared fields in the given class.- 参数:
clazz- the target class to analyzefc- the callback to invoke for each field- 抛出:
IllegalStateException- if introspection fails- 另请参阅:
-
doWithFields
Invoke the given callback on all fields in the target class, going up the class hierarchy to get all declared fields.- 参数:
clazz- the target class to analyzefc- the callback to invoke for each field- 抛出:
IllegalStateException- if introspection fails
-
doWithFields
public static void doWithFields(Class<?> clazz, ReflectionUtils.FieldCallback fc, @Nullable ReflectionUtils.FieldFilter ff) Invoke the given callback on all fields in the target class, going up the class hierarchy to get all declared fields.- 参数:
clazz- the target class to analyzefc- the callback to invoke for each fieldff- the filter that determines the fields to apply the callback to- 抛出:
IllegalStateException- if introspection fails
-
getDeclaredFields
This variant retrievesClass.getDeclaredFields()from a local cache in order to avoid the JVM's SecurityManager check and defensive array copying.- 参数:
clazz- the class to introspect- 返回:
- the cached array of fields
- 抛出:
IllegalStateException- if introspection fails- 另请参阅:
-
shallowCopyFieldState
Given the source object and the destination, which must be the same class or a subclass, copy all fields, including inherited fields. Designed to work on objects with public no-arg constructors.- 抛出:
IllegalStateException- if introspection fails
-
copyField
Copy a given field from the source object to the destination- 参数:
field- target field property
-
makeAccessible
Make the given field accessible, explicitly setting it accessible if necessary. ThesetAccessible(true)method is only called when actually necessary, to avoid unnecessary conflicts with a JVM SecurityManager (if active).- 参数:
field- the field to make accessible- 另请参阅:
-
isPublicStaticFinal
Determine whether the given field is a "public static final" constant.- 参数:
field- the field to check
-
toFieldArray
- 从以下版本开始:
- 4.0
-
accessibleConstructor
public static <T> Constructor<T> accessibleConstructor(Class<T> targetClass, Class<?>... parameterTypes) - 抛出:
ConstructorNotFoundException- not found- 从以下版本开始:
- 4.0
- 另请参阅:
-
makeAccessible
-
hasConstructor
Determine whether the given class has a declared constructor with the given signature.Essentially translates
NoSuchMethodExceptionto "false".- 参数:
clazz- the clazz to analyzeparamTypes- the parameter types of the method- 返回:
- whether the class has a corresponding constructor
- 从以下版本开始:
- 4.0
- 另请参阅:
-
getConstructorIfAvailable
@Nullable public static <T> Constructor<T> getConstructorIfAvailable(Class<T> clazz, Class<?>... paramTypes) Determine whether the given class has a declared constructor with the given signature, and return it if available (else returnnull).Essentially translates
NoSuchMethodExceptiontonull.- 参数:
clazz- the clazz to analyzeparamTypes- the parameter types of the method- 返回:
- the constructor, or
nullif not found - 从以下版本开始:
- 4.0
- 另请参阅:
-
getConstructor
getDeclaredConstructor- 抛出:
ConstructorNotFoundException- not found- 从以下版本开始:
- 4.0
- 另请参阅:
-
invokeConstructor
-
clearCache
public static void clearCache()Clear the internal method/field cache. -
obtainField
-
obtainMethod
-
findMethodWithMinimalParameters
@Nullable public static Method findMethodWithMinimalParameters(Class<?> clazz, String methodName) throws IllegalArgumentException Find a method with the given method name and minimal parameters (best case: none), declared on the given class or one of its superclasses. Prefers public methods, but will return a protected, package access, or private method too.Checks
Class.getMethodsfirst, falling back tofindDeclaredMethodWithMinimalParameters. This allows for finding public methods without issues even in environments with restricted Java security settings.- 参数:
clazz- the class to checkmethodName- the name of the method to find- 返回:
- the Method object, or
nullif not found - 抛出:
IllegalArgumentException- if methods of the given name were found but could not be resolved to a unique method with minimal parameters- 从以下版本开始:
- 4.0
- 另请参阅:
-
findDeclaredMethodWithMinimalParameters
@Nullable public static Method findDeclaredMethodWithMinimalParameters(Class<?> clazz, String methodName) throws IllegalArgumentException Find a method with the given method name and minimal parameters (best case: none), declared on the given class or one of its superclasses. Will return a public, protected, package access, or private method.Checks
Class.getDeclaredMethods, cascading upwards to all superclasses.- 参数:
clazz- the class to checkmethodName- the name of the method to find- 返回:
- the Method object, or
nullif not found - 抛出:
IllegalArgumentException- if methods of the given name were found but could not be resolved to a unique method with minimal parameters- 从以下版本开始:
- 4.0
- 另请参阅:
-
findMethodWithMinimalParameters
@Nullable public static Method findMethodWithMinimalParameters(Method[] methods, String methodName) throws IllegalArgumentException Find a method with the given method name and minimal parameters (best case: none) in the given list of methods.- 参数:
methods- the methods to checkmethodName- the name of the method to find- 返回:
- the Method object, or
nullif not found - 抛出:
IllegalArgumentException- if methods of the given name were found but could not be resolved to a unique method with minimal parameters- 从以下版本开始:
- 4.0
-
getReadMethod
find getter method- 从以下版本开始:
- 3.0.2
-
getReadMethod
@Nullable public static Method getReadMethod(Class<?> declaredClass, @Nullable Class<?> type, String name) find getter method- 从以下版本开始:
- 3.0.2
-
getWriteMethod
find setter method- 从以下版本开始:
- 3.0.2
-
getWriteMethod
@Nullable public static Method getWriteMethod(Class<?> declaredClass, @Nullable Class<?> type, String name) find setter method- 从以下版本开始:
- 3.0.2
-
getPropertyName
@Nullable public static String getPropertyName(@Nullable Method readMethod, @Nullable Method writeMethod) get property name from readMethod or writeMethod- 参数:
readMethod- get methodwriteMethod- set method- 返回:
- property name
-
getParameterIndex
GetParameterindex- 参数:
parameter-Parameter- 从以下版本开始:
- 3.0
-
getParameter
GetParameterwith givenparameterIndex- 参数:
executable-MethodorConstructor- 抛出:
IllegalArgumentException- parameter index is illegal- 从以下版本开始:
- 3.0
-
newInstance
Get instance with bean class- 参数:
beanClassName- bean class name string- 返回:
- the instance of target class
- 抛出:
ClassNotFoundException- If the class was not found- 从以下版本开始:
- 4.0
-
newInstance
- 从以下版本开始:
- 4.0
-
newInstance
- 从以下版本开始:
- 4.0
-
getProtectionDomain
- 从以下版本开始:
- 4.0
-