public abstract class Reflections extends Object
Modifier and Type | Method and Description |
---|---|
static <T> Class<T> |
classForName(String name) |
static Field |
findDeclaredField(Class<?> clazz,
String name)
Search the class hierarchy for a field with the given name.
|
static Method |
findDeclaredMethod(Class<?> clazz,
String name,
Class<?>... args)
Search the class hierarchy for a method with the given name and arguments.
|
static ClassLoader |
getClassLoader() |
static <T> T |
getFieldValue(Field field,
Object instance,
Class<T> expectedType) |
static <T> T |
invokeMethod(Method method,
Class<T> expectedReturnType,
Object instance,
Object... args) |
static <T> T |
newInstance(String className) |
static void |
setFieldValue(Field field,
Object instance,
Object value) |
public static <T> T newInstance(String className)
public static Method findDeclaredMethod(Class<?> clazz, String name, Class<?>... args)
clazz
- The class to searchname
- The name of the method to search forargs
- The arguments of the method to search forpublic static Field findDeclaredField(Class<?> clazz, String name)
clazz
- The class to searchname
- The name of the field to search forpublic static <T> T invokeMethod(Method method, Class<T> expectedReturnType, Object instance, Object... args)
public static <T> T getFieldValue(Field field, Object instance, Class<T> expectedType)
public static ClassLoader getClassLoader()
Copyright © 2016. All rights reserved.