|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.infinispan.util.ReflectionUtil
public class ReflectionUtil
Basic reflection utilities to enhance what the JDK provides.
Field Summary | |
---|---|
static Class<?>[] |
EMPTY_CLASS_ARRAY
|
Constructor Summary | |
---|---|
ReflectionUtil()
|
Method Summary | ||
---|---|---|
static String |
extractFieldName(String setterOrGetter)
|
|
static Method |
findGetterForField(Class<?> c,
String fieldName)
|
|
static Method |
findMethod(Class<?> type,
String methodName)
|
|
static Method |
findMethod(Class<?> type,
String methodName,
Class<?>[] parameters)
|
|
static Method |
findMethod(Class<?> type,
String methodName,
String[] parameters)
|
|
static Method |
findSetterForField(Class<?> c,
String fieldName)
|
|
static List<Method> |
getAllMethods(Class<?> c,
Class<? extends Annotation> annotationType)
Returns a set of Methods that contain the given method annotation. |
|
static List<Method> |
getAllMethodsShallow(Class<?> c,
Class<? extends Annotation> annotationType)
Returns a set of Methods that contain the given method annotation. |
|
static List<Field> |
getAnnotatedFields(Class<?> c,
Class<? extends Annotation> annotationType)
|
|
static
|
getAnnotation(Class<?> clazz,
Class<T> ann)
Inspects the class passed in for the class level annotation specified. |
|
static Class<?> |
getClassForName(String name,
ClassLoader cl)
|
|
static Field |
getField(String fieldName,
Class<?> objectClass)
|
|
static List<Field> |
getFields(Class<?> c,
Class<?> type)
|
|
static Object |
getValue(Object instance,
String fieldName)
Retrieves the value of a field of an object instance via reflection |
|
static Object |
invokeAccessibly(Object instance,
Method method,
Object[] parameters)
Invokes a method using reflection, in an accessible manner (by using AccessibleObject.setAccessible(boolean) |
|
static boolean |
isAnnotationPresent(Class<?> clazz,
Class<? extends Annotation> annotation)
Tests whether an annotation is present on a class. |
|
static boolean |
isGetMethod(Method method)
|
|
static boolean |
isIsMethod(Method method)
|
|
static boolean |
isSetMethod(Method method)
|
|
static void |
setValue(Object instance,
String fieldName,
Object value)
|
|
static Class<?>[] |
toClassArray(String[] typeList)
|
|
static String[] |
toStringArray(Class<?>[] classes)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Class<?>[] EMPTY_CLASS_ARRAY
Constructor Detail |
---|
public ReflectionUtil()
Method Detail |
---|
public static List<Method> getAllMethods(Class<?> c, Class<? extends Annotation> annotationType)
c
- class to inspectannotationType
- the type of annotation to look for
public static List<Method> getAllMethodsShallow(Class<?> c, Class<? extends Annotation> annotationType)
c
- class to inspectannotationType
- the type of annotation to look for
public static List<Field> getAnnotatedFields(Class<?> c, Class<? extends Annotation> annotationType)
public static List<Field> getFields(Class<?> c, Class<?> type)
public static Method findMethod(Class<?> type, String methodName)
public static Method findMethod(Class<?> type, String methodName, Class<?>[] parameters)
public static Method findMethod(Class<?> type, String methodName, String[] parameters) throws ClassNotFoundException
ClassNotFoundException
public static void setValue(Object instance, String fieldName, Object value)
public static Object invokeAccessibly(Object instance, Method method, Object[] parameters)
AccessibleObject.setAccessible(boolean)
instance
- instance on which to execute the methodmethod
- method to executeparameters
- parameterspublic static Method findGetterForField(Class<?> c, String fieldName)
public static Method findSetterForField(Class<?> c, String fieldName)
public static String extractFieldName(String setterOrGetter)
public static Object getValue(Object instance, String fieldName)
instance
- to inspectfieldName
- name of field to retrieve
public static <T extends Annotation> T getAnnotation(Class<?> clazz, Class<T> ann)
clazz
- class to inspectann
- annotation to search for. Must be a class-level annotation.
public static boolean isAnnotationPresent(Class<?> clazz, Class<? extends Annotation> annotation)
clazz
- class to testannotation
- annotation to look for
public static boolean isSetMethod(Method method)
public static boolean isGetMethod(Method method)
public static boolean isIsMethod(Method method)
public static Class<?>[] toClassArray(String[] typeList) throws ClassNotFoundException
ClassNotFoundException
public static Class<?> getClassForName(String name, ClassLoader cl) throws ClassNotFoundException
ClassNotFoundException
public static String[] toStringArray(Class<?>[] classes)
public static Field getField(String fieldName, Class<?> objectClass)
|
--> | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |