Package com.xxl.tool.core
Class ClassTool
java.lang.Object
com.xxl.tool.core.ClassTool
Class Tool
- Author:
- xuxueli 2024-01-21 05:03:10
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic MethodDetermine whether the given class has a public method with the given signature, and return it if available (else returnnull).static booleanisAssignable(Class<?> superType, Class<?> subType) Check if the super-type may be assigned to the sub-type Considers primitive wrapper classes as assignable to the corresponding primitive types.
-
Constructor Details
-
ClassTool
public ClassTool()
-
-
Method Details
-
isAssignable
Check if the super-type may be assigned to the sub-type Considers primitive wrapper classes as assignable to the corresponding primitive types.- Parameters:
superType- the target type (left-hand side (LHS) type)subType- the value type (right-hand side (RHS) type) that should be assigned to the target type- Returns:
trueifrhsTypeis assignable tolhsType
-
getMethod
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.- Parameters:
clazz- the clazz to analyzemethodName- the name of the methodparamTypes- the parameter types of the method (can benullto indicate any signature)- Returns:
- the method, or
nullif not found
-