|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.squirrelframework.foundation.util.ReflectUtils
public class ReflectUtils
| Nested Class Summary | |
|---|---|
static interface |
ReflectUtils.FieldCallback
Callback interface invoked on each field in the hierarchy. |
static interface |
ReflectUtils.FieldFilter
Callback optionally used to filter fields to be operated on by a field callback. |
static interface |
ReflectUtils.MethodCallback
Action to take on each method. |
static interface |
ReflectUtils.MethodFilter
Callback optionally used to filter methods to be operated on by a method callback. |
| Method Summary | ||
|---|---|---|
static void |
doWithFields(Class<?> clazz,
ReflectUtils.FieldCallback fc)
Invoke the given callback on all fields in the target class, going up the class hierarchy to get all declared fields. |
|
static void |
doWithFields(Class<?> clazz,
ReflectUtils.FieldCallback fc,
ReflectUtils.FieldFilter ff)
Invoke the given callback on all fields in the target class, going up the class hierarchy to get all declared fields. |
|
static void |
doWithMethods(Class<?> clazz,
ReflectUtils.MethodCallback mc)
Perform the given callback operation on all matching methods of the given class and superclasses. |
|
static void |
doWithMethods(Class<?> clazz,
ReflectUtils.MethodCallback mc,
ReflectUtils.MethodFilter mf)
Perform the given callback operation on all matching methods of the given class and superclasses (or given interface and super-interfaces). |
|
static Object |
get(Field field,
Object object)
|
|
static Set<Field> |
getAllDeclaredFields(Class<?> theClass)
|
|
static Field[] |
getAnnotatedFields(Class<?> targetClass,
Class<? extends Annotation> annotationClass)
|
|
static List<Method> |
getAnnotatedMethods(Class<?> targetClass,
Class<? extends Annotation> annotationClass)
|
|
static
|
getAnnotation(Class<?> theClass,
Class<T> theAnnotation)
Return the given annotation from the class. |
|
static Class<?> |
getClass(String className)
|
|
static
|
getConstructor(Class<T> type,
Class<?>[] parameterTypes)
|
|
static Field |
getField(Class<?> clazz,
String fieldName)
searches for the field in the given class and in its super classes |
|
static Method |
getFirstMethodOfName(Class<?> clazz,
String name)
|
|
static Method |
getMethod(Class<?> clazz,
String methodName,
Class<?>[] parameterTypes)
searches for the method in the given class and in its super classes |
|
static String |
getPackageName(String className)
|
|
static Object |
getStatic(Field field)
|
|
static Class<?>[] |
getSuperclasses(Class<?> type)
Returns all superclasses. |
|
static boolean |
hasAnnotation(Class<?> theClass,
Class<? extends Annotation> theAnnotation)
Return whether or not the class has the given annotation. |
|
static Object |
invoke(Method method,
Object target)
|
|
static Object |
invoke(Method method,
Object target,
Object[] args)
|
|
static Object |
invokeStatic(Method method)
|
|
static Object |
invokeStatic(Method method,
Object[] args)
|
|
static boolean |
isAnnotatedWith(Object obj,
Class<? extends Annotation> theAnnotation)
|
|
static boolean |
isBeanProperty(Method method)
Returns true if method is a bean property. |
|
static boolean |
isUserDefinedMethod(Method method)
Returns true if method is user defined and not defined in Object class. |
|
static String |
logMethod(Method method)
|
|
static
|
newInstance(Class<T> clazz)
|
|
static
|
newInstance(Constructor<T> constructor)
|
|
static
|
newInstance(Constructor<T> constructor,
Object[] args)
|
|
static
|
newInstance(String className)
|
|
static void |
set(Field field,
Object object,
Object value)
|
|
static void |
setStatic(Field field,
Object value)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static Set<Field> getAllDeclaredFields(Class<?> theClass)
public static Field getField(Class<?> clazz,
String fieldName)
public static Method getMethod(Class<?> clazz,
String methodName,
Class<?>[] parameterTypes)
public static String logMethod(Method method)
public static <T extends Annotation> T getAnnotation(Class<?> theClass,
Class<T> theAnnotation)
theClass - the class to inspecttheAnnotation - the annotation to retrieve
public static boolean hasAnnotation(Class<?> theClass,
Class<? extends Annotation> theAnnotation)
theClass - the class to checktheAnnotation - the annotation to look for
public static List<Method> getAnnotatedMethods(Class<?> targetClass,
Class<? extends Annotation> annotationClass)
public static Field[] getAnnotatedFields(Class<?> targetClass,
Class<? extends Annotation> annotationClass)
public static boolean isAnnotatedWith(Object obj,
Class<? extends Annotation> theAnnotation)
public static Method getFirstMethodOfName(Class<?> clazz,
String name)
public static <T> Constructor<T> getConstructor(Class<T> type,
Class<?>[] parameterTypes)
public static <T> T newInstance(String className)
public static <T> T newInstance(Class<T> clazz)
public static <T> T newInstance(Constructor<T> constructor)
public static <T> T newInstance(Constructor<T> constructor,
Object[] args)
public static Object getStatic(Field field)
public static Object get(Field field,
Object object)
public static void setStatic(Field field,
Object value)
public static void set(Field field,
Object object,
Object value)
public static Object invokeStatic(Method method)
public static Object invokeStatic(Method method,
Object[] args)
public static Object invoke(Method method,
Object target)
public static Object invoke(Method method,
Object target,
Object[] args)
public static void doWithFields(Class<?> clazz,
ReflectUtils.FieldCallback fc)
throws IllegalArgumentException
clazz - the target class to analyzefc - the callback to invoke for each field
IllegalArgumentException
public static void doWithFields(Class<?> clazz,
ReflectUtils.FieldCallback fc,
ReflectUtils.FieldFilter ff)
throws IllegalArgumentException
clazz - the target class to analyzefc - the callback to invoke for each fieldff - the filter that determines the fields to apply the callback to
IllegalArgumentException
public static void doWithMethods(Class<?> clazz,
ReflectUtils.MethodCallback mc)
throws IllegalArgumentException
The same named method occurring on subclass and superclass will appear
twice, unless excluded by a ReflectUtils.MethodFilter.
clazz - class to start looking atmc - the callback to invoke for each method
IllegalArgumentExceptiondoWithMethods(Class, MethodCallback, MethodFilter)
public static void doWithMethods(Class<?> clazz,
ReflectUtils.MethodCallback mc,
ReflectUtils.MethodFilter mf)
throws IllegalArgumentException
The same named method occurring on subclass and superclass will appear
twice, unless excluded by the specified ReflectUtils.MethodFilter.
clazz - class to start looking atmc - the callback to invoke for each methodmf - the filter that determines the methods to apply the callback to
IllegalArgumentExceptionpublic static Class<?>[] getSuperclasses(Class<?> type)
public static boolean isUserDefinedMethod(Method method)
true if method is user defined and not defined in Object class.
public static boolean isBeanProperty(Method method)
true if method is a bean property.
public static String getPackageName(String className)
public static Class<?> getClass(String className)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||