public class Reflections extends Object
| Constructor and Description |
|---|
Reflections() |
| Modifier and Type | Method and Description |
|---|---|
static Class<?> |
classForName(String name) |
static Object |
get(Field field,
Object target) |
static Object |
get(Object object,
String fieldName) |
static <T> T |
get(Object object,
String fieldName,
Class<T> valueClass) |
static Object |
getAndWrap(Field field,
Object target) |
static Class<?> |
getCollectionElementType(Type collectionType) |
static Field |
getField(Class<?> clazz,
String name) |
static List<Field> |
getFields(Class<?> clazz,
Class<? extends Annotation> annotation)
Get all the fields which are annotated with the given annotation.
|
static Method |
getGetterMethod(Class<?> clazz,
String name) |
static List<Method> |
getGetterMethods(Class<?> clazz,
Class<? extends Annotation> annotation)
Get all the getter methods annotated with the given annotation.
|
static Class<?> |
getMapKeyType(Type collectionType) |
static Method |
getMethod(Annotation annotation,
String name) |
static Method |
getSetterMethod(Class<?> clazz,
String name) |
static Object |
invoke(Method method,
Object target,
Object... args) |
static Object |
invokeAndWrap(Method method,
Object target,
Object... args) |
static boolean |
isClassAvailable(String name)
Return's true if the class can be loaded using Reflections.classForName()
|
static boolean |
isInstanceOf(Class<?> clazz,
String name) |
static void |
set(Field field,
Object target,
Object value) |
static void |
setAndWrap(Field field,
Object target,
Object value) |
public Reflections()
public static Object invoke(Method method, Object target, Object... args) throws Exception
Exceptionpublic static void set(Field field, Object target, Object value) throws Exception
Exceptionpublic static Object getAndWrap(Field field, Object target)
public static void setAndWrap(Field field, Object target, Object value)
public static Object invokeAndWrap(Method method, Object target, Object... args)
public static Class<?> classForName(String name) throws ClassNotFoundException
ClassNotFoundExceptionpublic static boolean isClassAvailable(String name)
public static Class<?> getCollectionElementType(Type collectionType)
public static Class<?> getMapKeyType(Type collectionType)
public static Method getSetterMethod(Class<?> clazz, String name)
public static Method getGetterMethod(Class<?> clazz, String name)
public static List<Method> getGetterMethods(Class<?> clazz, Class<? extends Annotation> annotation)
public static List<Field> getFields(Class<?> clazz, Class<? extends Annotation> annotation)
public static Method getMethod(Annotation annotation, String name)
public static boolean isInstanceOf(Class<?> clazz, String name)