public class ReflectionUtils extends Object
Constructor and Description |
---|
ReflectionUtils() |
Modifier and Type | Method and Description |
---|---|
static Object |
getFieldVal(Object obj,
String fieldName)
Get the value of the named field in the class of the given object or any of its superclasses.
|
static Object |
getStaticFieldVal(Class<?> cls,
String fieldName)
Get the value of the named static field in the given class or any of its superclasses.
|
static Object |
invokeMethod(Object obj,
String methodName)
Invoke the named method in the given object or its superclasses.
|
static Object |
invokeMethod(Object obj,
String methodName,
Class<?> argType,
Object arg)
Invoke the named method in the given object or its superclasses.
|
static Object |
invokeStaticMethod(Class<?> cls,
String methodName)
Invoke the named static method.
|
static Object |
invokeStaticMethod(Class<?> cls,
String methodName,
Class<?> argType,
Object arg)
Invoke the named static method.
|
static String |
modifiersToString(int modifiers,
boolean isMethod)
Convert field or method modifiers into a string representation, e.g.
|
static List<String> |
parseComplexTypeDescriptor(String typeDescriptor)
Parse a type descriptor into a type or list of types.
|
static String |
parseSimpleTypeDescriptor(String typeDescriptor)
Parse a simple Java type descriptor (for a single type -- methods are not supported), and turn it into a type
string, e.g.
|
static Class<?> |
typeStrToClass(String typeStr,
ScanResult scanResult)
Parse a type string (e.g.
|
public static Object getFieldVal(Object obj, String fieldName) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException
public static Object getStaticFieldVal(Class<?> cls, String fieldName) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException
public static Object invokeMethod(Object obj, String methodName) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
public static Object invokeMethod(Object obj, String methodName, Class<?> argType, Object arg) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
public static Object invokeStaticMethod(Class<?> cls, String methodName) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
public static Object invokeStaticMethod(Class<?> cls, String methodName, Class<?> argType, Object arg) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
public static String modifiersToString(int modifiers, boolean isMethod)
public static List<String> parseComplexTypeDescriptor(String typeDescriptor)
public static String parseSimpleTypeDescriptor(String typeDescriptor)
public static Class<?> typeStrToClass(String typeStr, ScanResult scanResult) throws IllegalArgumentException
typeStr
- The type string.scanResult
- the ScanResult (used to call the correct ClassLoader(s)).IllegalArgumentException
- if the class could not be found or loaded.Copyright © 2017. All rights reserved.