|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.akquinet.jbosscc.needle.reflection.ReflectionUtil
public final class ReflectionUtil
| Method Summary | ||
|---|---|---|
static
|
createInstance(Class<T> clazz,
Object... parameter)
|
|
static Class<?> |
forName(String className)
Returns the Class object associated with the class or
interface with the given string name. |
|
static Map<Class<? extends Annotation>,List<Field>> |
getAllAnnotatedFields(Class<?> clazz)
|
|
static List<Field> |
getAllFields(Class<?> clazz)
|
|
static List<Field> |
getAllFieldsAssinableFrom(Class<?> assinableType,
Class<?> clazz)
|
|
static List<Field> |
getAllFieldsWithAnnotation(Class<?> clazz,
Class<? extends Annotation> annotation)
|
|
static List<Field> |
getAllFieldsWithAnnotation(Object instance,
Class<? extends Annotation> annotation)
|
|
static Set<Class<?>> |
getClasses(String... classNames)
|
|
static Field |
getField(Class<?> clazz,
String fieldName)
|
|
static Object |
getFieldValue(Object object,
Class<?> clazz,
String fieldName)
Get the value of a given field on a given object via reflection. |
|
static Object |
getFieldValue(Object object,
Field field)
Get the value of a given field on a given object via reflection. |
|
static Object |
getFieldValue(Object object,
String fieldName)
Get the value of a given field on a given object via reflection. |
|
static Method |
getMethod(Class<?> clazz,
String methodName,
Class<?>... parameterTypes)
|
|
static List<Method> |
getMethods(Class<?> clazz)
|
|
static Object |
invokeMethod(Method method,
Object instance,
Object... arguments)
|
|
static Object |
invokeMethod(Object object,
Class<?> clazz,
String methodName,
Object... arguments)
Invoke a given method with given arguments on a given object via reflection. |
|
static Object |
invokeMethod(Object object,
String methodName,
Object... arguments)
Invoke a given method with given arguments on a given object via reflection. |
|
static void |
setField(Field field,
Object target,
Object value)
|
|
static void |
setField(String fieldName,
Object target,
Object value)
|
|
static void |
setFieldValue(Object object,
Class<?> clazz,
String fieldName,
Object value)
Changing the value of a given field. |
|
static void |
setFieldValue(Object object,
String fieldName,
Object value)
Changing the value of a given field. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static List<Field> getAllFieldsWithAnnotation(Class<?> clazz,
Class<? extends Annotation> annotation)
public static Map<Class<? extends Annotation>,List<Field>> getAllAnnotatedFields(Class<?> clazz)
public static List<Field> getAllFieldsAssinableFrom(Class<?> assinableType,
Class<?> clazz)
public static List<Field> getAllFieldsWithAnnotation(Object instance,
Class<? extends Annotation> annotation)
public static List<Field> getAllFields(Class<?> clazz)
public static List<Method> getMethods(Class<?> clazz)
class - object
Class.getMethods()
public static void setFieldValue(Object object,
Class<?> clazz,
String fieldName,
Object value)
throws NoSuchFieldException
object - -- target object of injectionclazz - -- type of argument objectfieldName - -- name of field whose value is to be setvalue - -- object that is injected
NoSuchFieldException
public static void setFieldValue(Object object,
String fieldName,
Object value)
object - -- target object of injectionfieldName - -- name of field whose value is to be setvalue - -- object that is injected
public static Object getFieldValue(Object object,
Class<?> clazz,
String fieldName)
object - -- target object of field accessclazz - -- type of argument objectfieldName - -- name of the field
public static Object getFieldValue(Object object,
Field field)
object - -- target object of field accessfield - -- target field
public static Object getFieldValue(Object object,
String fieldName)
object - -- target object of field accessfieldName - -- name of the field
public static Object invokeMethod(Object object,
Class<?> clazz,
String methodName,
Object... arguments)
throws Exception
object - -- target object of invocationclazz - -- type of argument objectmethodName - -- name of method to be invokedarguments - -- arguments for method invocation
Exception - - operation exception
public static Object invokeMethod(Method method,
Object instance,
Object... arguments)
throws Exception
Exception
public static Method getMethod(Class<?> clazz,
String methodName,
Class<?>... parameterTypes)
throws NoSuchMethodException
NoSuchMethodException
public static Object invokeMethod(Object object,
String methodName,
Object... arguments)
throws Exception
object - -- target object of invocationmethodName - -- name of method to be invokedarguments - -- arguments for method invocation
Exceptionpublic static Set<Class<?>> getClasses(String... classNames)
public static Class<?> forName(String className)
Class object associated with the class or
interface with the given string name.
className - the fully qualified name of the desired class.
Class or null
public static void setField(Field field,
Object target,
Object value)
throws Exception
Exception
public static void setField(String fieldName,
Object target,
Object value)
throws Exception
Exception
public static Field getField(Class<?> clazz,
String fieldName)
public static <T> T createInstance(Class<T> clazz,
Object... parameter)
throws Exception
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||