public class ReflectKit extends Object
构造器和说明 |
---|
ReflectKit() |
限定符和类型 | 方法和说明 |
---|---|
static <T> T |
cast(Object value,
Class<T> type)
Converts value to a specified type
|
static Object |
convert(Type type,
String value)
Converts a string type to a target type
|
static Class<?> |
form(String typeName)
Load a class according to the class name.
|
static Class<?> |
getClass(Type type) |
static String |
getClassName(Type type) |
static Method |
getMethod(Class<?> cls,
String methodName,
Class<?>... types)
Get cls method name by name and parameter types
|
static boolean |
hasInterface(Class<?> cls,
Class<?> inter)
Determine whether CLS is an implementation of an inteface Type.
|
static Object |
invokeMethod(Object bean,
Method method,
Object... args)
invoke method
|
static boolean |
is(Object instance,
Object... maybeValues)
Whether the object is one of them.
|
static boolean |
isArray(Type type) |
static boolean |
isBasicType(Object bean) |
static boolean |
isBasicType(Type type) |
static boolean |
isNormalClass(Class<?> cls)
Determine whether cls belong to a normal type
|
static boolean |
isPrimitive(Object bean) |
static boolean |
isPrimitive(Type type)
Is cls a basic type
|
static List<Field> |
loopFields(Class<?> type) |
static <T> T |
newInstance(Type type)
Create an instance of the none constructor.
|
static void |
setFieldValue(Field field,
Object target,
Object value) |
static Class<?> |
typeToClass(Type type) |
public static <T> T newInstance(Type type)
T
- target typetype
- target typepublic static Class<?> getClass(Type type) throws ClassNotFoundException
public static Object convert(Type type, String value)
type
- target typevalue
- string valuepublic static Object invokeMethod(Object bean, Method method, Object... args) throws Exception
bean
- bean instancemethod
- method instanceargs
- method argumentsException
- throws Exceptionpublic static <T> T cast(Object value, Class<T> type)
T
- target typevalue
- instance valuetype
- target typepublic static boolean is(Object instance, Object... maybeValues)
instance
- instancemaybeValues
- public static boolean hasInterface(Class<?> cls, Class<?> inter)
cls
- inter
- public static boolean isNormalClass(Class<?> cls)
cls
- public static Method getMethod(Class<?> cls, String methodName, Class<?>... types)
cls
- methodName
- types
- public static boolean isPrimitive(Object bean)
public static boolean isPrimitive(Type type)
type
- Class typepublic static boolean isBasicType(Object bean)
public static boolean isBasicType(Type type)
public static boolean isArray(Type type)
public static Class<?> form(String typeName)
typeName
- Copyright © 2018. All rights reserved.